add tcp sketch

add tcp sketch

error: pathspec 'tcp-sketch/tcp-sketch.ino' did not match any file(s) known to git

--- tcp-sketch/tcp-sketch.ino
+++ tcp-sketch/tcp-sketch.ino
@@ -0,0 +1,195 @@
+
+/***************************************************
+  Adafruit CC3000 Breakout/Shield TCP Echo Server
+
+  This is a simple implementation of the echo
+  protocol, RFC 862 http://tools.ietf.org/html/rfc862 ,
+  for the Arduino platform and Adafruit CC3000 breakout
+  or shield.  This sketch will create a TCP server that
+  listens by default on port 7 and echos back any data
+  received.  Up to 3 clients can be connected concurrently
+  to the server.  This sketch is meant as an example of how
+  to write a simple server with the Arduino and CC3000.
+
+  See the CC3000 tutorial on Adafruit's learning system
+  for more information on setting up and using the
+  CC3000:
+    http://learn.adafruit.com/adafruit-cc3000-wifi
+
+  Requirements:
+
+  This sketch requires the Adafruit CC3000 library.  You can
+  download the library from:
+    https://github.com/adafruit/Adafruit_CC3000_Library
+
+  For information on installing libraries in the Arduino IDE
+  see this page:
+    http://arduino.cc/en/Guide/Libraries
+
+  Usage:
+
+  Update the SSID and, if necessary, the CC3000 hardware pin
+  information below, then run the sketch and check the
+  output of the serial port.  After connecting to the
+  wireless network successfully the sketch will output
+  the IP address of the server and start listening for
+  connections.  Once listening for connections, connect
+  to the server from your computer  using a telnet client
+  on port 7.
+
+  For example on Linux or Mac OSX, if your CC3000 has an
+  IP address 192.168.1.100 you would execute in a command
+  window:
+
+    telnet 192.168.1.100 7
+
+  After connecting, notice that as you type input and
+  press enter to send it the CC3000 will echo back exactly
+  what you typed.  Press ctrl-] and type quit at the prompt
+  to close the telnet session.
+
+  On Windows you'll need to download a telnet client.  PuTTY
+  is a good, free GUI client:
+    http://www.chiark.greenend.org.uk/~sgtatham/putty/
+
+  License:
+
+  This example is copyright (c) 2013 Tony DiCola (tony@tonydicola.com)
+  and is released under an open source MIT license.  See details at:
+    http://opensource.org/licenses/MIT
+
+  This code was adapted from Adafruit CC3000 library example
+  code which has the following license:
+
+  Designed specifically to work with the Adafruit WiFi products:
+  ----> https://www.adafruit.com/products/1469
+
+  Adafruit invests time and resources providing this open source code,
+  please support Adafruit and open-source hardware by purchasing
+  products from Adafruit!
+
+  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
+  BSD license, all text above must be included in any redistribution
+ ****************************************************/
+#include <Adafruit_CC3000.h>
+#include <SPI.h>
+#include "utility/debug.h"
+#include "utility/socket.h"
+
+// These are the interrupt and control pins
+#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
+// These can be any two pins
+#define ADAFRUIT_CC3000_VBAT  5
+#define ADAFRUIT_CC3000_CS    10
+// Use hardware SPI for the remaining pins
+// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
+Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
+                                         SPI_CLOCK_DIVIDER); // you can change this clock speed
+
+#define WLAN_SSID       "CL Eng Devices"           // cannot be longer than 32 characters!
+#define WLAN_PASS       "mak3 all the Things talk"
+// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
+#define WLAN_SECURITY   WLAN_SEC_WPA2
+
+#define LISTEN_PORT           7    // What TCP port to listen on for connections.  The echo protocol uses port 7.
+
+Adafruit_CC3000_Server echoServer(LISTEN_PORT);
+
+int led = 8;
+
+void setup(void)
+{
+  pinMode(led, OUTPUT);
+  Serial.begin(115200);
+  Serial.println(F("Hello, CC3000!\n"));
+
+  Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);
+
+  /* Initialise the module */
+  Serial.println(F("\nInitializing..."));
+  if (!cc3000.begin())
+  {
+    Serial.println(F("Couldn't begin()! Check your wiring?"));
+    while(1);
+  }
+
+  Serial.print(F("\nAttempting to connect to ")); Serial.println(WLAN_SSID);
+  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
+    Serial.println(F("Failed!"));
+    while(1);
+  }
+
+  Serial.println(F("Connected!"));
+
+  Serial.println(F("Request DHCP"));
+  while (!cc3000.checkDHCP())
+  {
+    delay(100); // ToDo: Insert a DHCP timeout!
+  }
+
+  /* Display the IP address DNS, Gateway, etc. */
+  while (! displayConnectionDetails()) {
+    delay(1000);
+  }
+
+  /*********************************************************/
+  /* You can safely remove this to save some flash memory! */
+  /*********************************************************/
+  Serial.println(F("\r\nNOTE: This sketch may cause problems with other sketches"));
+  Serial.println(F("since the .disconnect() function is never called, so the"));
+  Serial.println(F("AP may refuse connection requests from the CC3000 until a"));
+  Serial.println(F("timeout period passes.  This is normal behaviour since"));
+  Serial.println(F("there isn't an obvious moment to disconnect with a server.\r\n"));
+
+  // Start listening for connections
+  echoServer.begin();
+
+  Serial.println(F("Listening for connections..."));
+}
+
+void loop(void)
+{
+  // Try to get a client which is connected.
+  Adafruit_CC3000_ClientRef client = echoServer.available();
+  if (client) {
+     // Check if there is data available to read.
+     if (client.available() > 0) {
+       // Read a byte and write it to all clients.
+       uint8_t ch = client.read();
+       client.write(ch);
+       if (ch == 49) {
+         digitalWrite(led, HIGH);
+       } else if (ch ==50) {
+         digitalWrite(led, LOW);
+       } else {
+         Serial.println(ch);
+       }
+     }
+  }
+}
+
+/**************************************************************************/
+/*!
+    @brief  Tries to read the IP address and other connection details
+*/
+/**************************************************************************/
+bool displayConnectionDetails(void)
+{
+  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
+
+  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
+  {
+    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
+    return false;
+  }
+  else
+  {
+    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
+    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
+    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
+    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
+    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
+    Serial.println();
+    return true;
+  }
+}


Add echo server example.

Add echo server example.

error: pathspec 'echoserver/echoserver.ino' did not match any file(s) known to git

--- echoserver/echoserver.ino
+++ echoserver/echoserver.ino
@@ -0,0 +1,347 @@
+
+/***************************************************
+  Adafruit CC3000 Breakout/Shield TCP Echo Server
+
+  This is a simple implementation of the echo
+  protocol, RFC 862 http://tools.ietf.org/html/rfc862 ,
+  for the Arduino platform and Adafruit CC3000 breakout
+  or shield.  This sketch will create a TCP server that
+  listens by default on port 7 and echos back any data
+  received.  Up to 3 clients can be connected concurrently
+  to the server.  This sketch is meant as an example of how
+  to write a simple server with the Arduino and CC3000.
+
+  See the CC3000 tutorial on Adafruit's learning system
+  for more information on setting up and using the
+  CC3000:
+    http://learn.adafruit.com/adafruit-cc3000-wifi
+
+  Requirements:
+
+  This sketch requires the Adafruit CC3000 library.  You can
+  download the library from:
+    https://github.com/adafruit/Adafruit_CC3000_Library
+
+  For information on installing libraries in the Arduino IDE
+  see this page:
+    http://arduino.cc/en/Guide/Libraries
+
+  Usage:
+
+  Update the SSID and, if necessary, the CC3000 hardware pin
+  information below, then run the sketch and check the
+  output of the serial port.  After connecting to the
+  wireless network successfully the sketch will output
+  the IP address of the server and start listening for
+  connections.  Once listening for connections, connect
+  to the server from your computer  using a telnet client
+  on port 7.
+
+  For example on Linux or Mac OSX, if your CC3000 has an
+  IP address 192.168.1.100 you would execute in a command
+  window:
+
+    telnet 192.168.1.100 7
+
+  After connecting, notice that as you type input and
+  press enter to send it the CC3000 will echo back exactly
+  what you typed.  Press ctrl-] and type quit at the prompt
+  to close the telnet session.
+
+  On Windows you'll need to download a telnet client.  PuTTY
+  is a good, free GUI client:
+    http://www.chiark.greenend.org.uk/~sgtatham/putty/
+
+  License:
+
+  This example is copyright (c) 2013 Tony DiCola (tony@tonydicola.com)
+  and is released under an open source MIT license.  See details at:
+    http://opensource.org/licenses/MIT
+
+  This code was adapted from Adafruit CC3000 library example
+  code which has the following license:
+
+  Designed specifically to work with the Adafruit WiFi products:
+  ----> https://www.adafruit.com/products/1469
+
+  Adafruit invests time and resources providing this open source code,
+  please support Adafruit and open-source hardware by purchasing
+  products from Adafruit!
+
+  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
+  BSD license, all text above must be included in any redistribution
+ ****************************************************/
+#include <Adafruit_CC3000.h>
+#include <SPI.h>
+#include "utility/debug.h"
+#include "utility/socket.h"
+
+// These are the interrupt and control pins
+#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
+// These can be any two pins
+#define ADAFRUIT_CC3000_VBAT  5
+#define ADAFRUIT_CC3000_CS    10
+// Use hardware SPI for the remaining pins
+// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
+Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
+                                         SPI_CLOCK_DIV2); // you can change this clock speed
+
+#define WLAN_SSID       "myNetwork"           // cannot be longer than 32 characters!
+#define WLAN_PASS       "myPassword"
+// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
+#define WLAN_SECURITY   WLAN_SEC_WPA2
+
+#define LISTEN_PORT           7    // What TCP port to listen on for connections.  The echo protocol uses port 7.
+#define MAX_CLIENTS           3    // The CC3000 docs advise that it has 4 sockets available to client code.
+                                   // One socket is consumed listening for new connections, and the remaining sockets
+                                   // are available for client connections.
+                                   // In practice it appears you can go higher than 4 sockets (up to about 7), but
+                                   // be careful as it might cause the CC3000 to behave unexpectedly.
+
+// Define a simple forward linked list structure to keep track of
+// connected clients.  This client list is kept as a linked list
+// because the CC3000 client instances have a non-trivial amount of
+// internal state (buffers, etc.) which we don't want to spend memory
+// consuming unless a client is connected.  Because the size of the list
+// is small and random access to entries is rare (happens only on
+// disconnect) a forward list (i.e. no back/previous pointer) is
+// sufficient.
+struct ClientList {
+  int socket;
+  Adafruit_CC3000_Client client;
+  ClientList* next;
+};
+
+// Global variable to hold the ID of the listening socket.
+int listenSocket;
+
+// Global variable to hold the start of the connected client list.
+ClientList* clients;
+
+// Global variable to keep track of how many clients are connected.
+int clientCount;
+
+// Function to add a new client to the connected client list.
+void addNewClient(int socket) {
+  // Allocate memory for a new list entry.
+  // In general be very careful with heap/dynamic memory use in an Arduino sketch
+  // because the function stack and heap share the same limited amount of memory and
+  // can easily overflow.  In this case the number of connected clients is low
+  // so the risk of using up all the memory is low.
+  ClientList* client = (ClientList*) malloc(sizeof(ClientList));
+  if (client == NULL) {
+    Serial.println(F("Error! Couldn't allocate space to store a new client."));
+    return;
+  }
+  // Setup the new client as the front of the connected client list.
+  client->next = clients;
+  client->socket = socket;
+  client->client = Adafruit_CC3000_Client(socket);
+  clients = client;
+  // Increment the count of connected clients.
+  clientCount++;
+}
+
+// Remove a client from the connected client list.
+void removeClient(struct ClientList* client) {
+  if (client == NULL) {
+    // Handle null client to delete.  This should never happen
+    // but is good practice as a precaution.
+    return;
+  }
+  if (clients == client) {
+    // Handle the client to delete being at the front of the list.
+    clients = client->next;
+  }
+  else {
+    // Handle the client to delete being somewhere inside the list.
+    // Iterate through the list until we find the entry before the
+    // client to delete.
+    ClientList* i = clients;
+    while (i != NULL && i->next != client) {
+      i = i->next;
+    }
+    if (i == NULL) {
+      // Couldn't find the client to delete, do nothing.
+      return;
+    }
+    // Remove the client from the list.
+    i->next = client->next;
+  }
+  // Free the memory associated with the client and set the
+  // pointer to null as a precaution against dangling references.
+  free(client);
+  client = NULL;
+  // Decrement the count of connected clients.
+  clientCount--;
+}
+
+// Set up the echo server and start listening for connections.  Should be called once
+// in the setup function of the Arduino sketch.
+void echoSetup() {
+  // Most of the calls below are to CC3000 firmware API's. You can find the documentaiton for these calls at:
+  //   http://software-dl.ti.com/ecs/simplelink/cc3000/public/doxygen_API/v1.11.1/html/index.html
+
+  // Set the CC3000 inactivity timeout to 0 (never timeout).  This will ensure the CC3000
+  // does not close the listening socket when it's idle for more than 60 seconds (the
+  // default timeout).  See more information from:
+  //   http://e2e.ti.com/support/low_power_rf/f/851/t/292664.aspx
+  unsigned long aucDHCP       = 14400;
+  unsigned long aucARP        = 3600;
+  unsigned long aucKeepalive  = 30;
+  unsigned long aucInactivity = 0;
+  if (netapp_timeout_values(&aucDHCP, &aucARP, &aucKeepalive, &aucInactivity) != 0) {
+    Serial.println(F("Error setting inactivity timeout!"));
+    while(1);
+  }
+  // Create a TCP socket
+  listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+  if (listenSocket < 0) {
+    Serial.println(F("Couldn't create listening socket!"));
+    while(1);
+  }
+  // Set the socket's accept call as non-blocking.
+  // This is required to support multiple clients accessing the server at once.  If the listening
+  // port is not set as non-blocking your code can't do anything while it waits for a client to connect.
+  if (setsockopt(listenSocket, SOL_SOCKET, SOCKOPT_ACCEPT_NONBLOCK, SOCK_ON, sizeof(SOCK_ON)) < 0) {
+    Serial.println(F("Couldn't set socket as non-blocking!"));
+    while(1);
+  }
+  // Bind the socket to a TCP address.
+  sockaddr_in address;
+  address.sin_family = AF_INET;
+  address.sin_addr.s_addr = htonl(0);     // Listen on any network interface, equivalent to INADDR_ANY in sockets programming.
+  address.sin_port = htons(LISTEN_PORT);  // Listen on the specified port.
+  if (bind(listenSocket, (sockaddr*) &address, sizeof(address)) < 0) {
+    Serial.println(F("Error binding listen socket to address!"));
+    while(1);
+  }
+  // Start listening for connectings.
+  // The backlog parameter is 0 as it is not supported on TI's CC3000 firmware.
+  if (listen(listenSocket, 0) < 0) {
+    Serial.println(F("Error opening socket for listening!"));
+    while(1);
+  }
+  // Initialize client list as empty.
+  clients = NULL;
+  clientCount = 0;
+  Serial.println(F("Listening for connections..."));
+}
+
+// Update the state of clients, and accept new client connections.  Should be called
+// by the Arduino sketch's loop function.
+void echoLoop() {
+  // Iterate through all the connected clients.
+  ClientList* i = clients;
+  while (i != NULL) {
+    // Save the next client so the current one can be removed when it disconnects
+    // without breaking iteration through the clients.
+    ClientList* next = i->next;
+    // If there's data available, read it a character at a time from the
+    // CC3000 library's internal buffer.
+    while (i->client.available() > 0) {
+      uint8_t ch = i->client.read();
+      // Echo the read byte back out to the client immediately.
+      if (i->client.write(ch) == 0) {
+        Serial.println(F("Error writing character to client!"));
+      }
+    }
+    // Check if the client is disconnected and remove it from the active client list.
+    if (!i->client.connected()) {
+      Serial.print(F("Client on socket "));
+      Serial.print(i->socket);
+      Serial.println(F(" disconnected."));
+      removeClient(i);
+      // Note that i is now NULL!  Don't try to dereference it or you will
+      // have a bad day (your Arduino will reset).
+    }
+    // Continue iterating through clients.
+    i = next;
+  }
+  // Handle new client connections if we aren't at the limit of connected clients.
+  if (clientCount < MAX_CLIENTS) {
+    // Accept a new socket connection.  Because we set the listening socket to be non-blocking
+    // this will quickly return a result with either a new socket, an indication that nothing
+    // is trying to connect, or an error.
+    // The NULL parameters allow you to read the address of the connected client but are
+    // unused in this sketch.  See TI's documentation (linked in the setup function) for
+    // more details.
+    int newSocket = accept(listenSocket, NULL, NULL);
+    // Check if a client is connected to a new socket.
+    if (newSocket > -1) {
+      Serial.print(F("New client connected on socket "));
+      Serial.println(newSocket);
+      // Add the client to the list of connected clients.
+      addNewClient(newSocket);
+    }
+  }
+}
+
+void setup(void)
+{
+  Serial.begin(115200);
+  Serial.println(F("Hello, CC3000!\n"));
+
+  Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);
+
+  /* Initialise the module */
+  Serial.println(F("\nInitializing..."));
+  if (!cc3000.begin())
+  {
+    Serial.println(F("Couldn't begin()! Check your wiring?"));
+    while(1);
+  }
+
+  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
+    Serial.println(F("Failed!"));
+    while(1);
+  }
+
+  Serial.println(F("Connected!"));
+
+  Serial.println(F("Request DHCP"));
+  while (!cc3000.checkDHCP())
+  {
+    delay(100); // ToDo: Insert a DHCP timeout!
+  }
+
+  /* Display the IP address DNS, Gateway, etc. */
+  while (! displayConnectionDetails()) {
+    delay(1000);
+  }
+
+  // Initialize the echo server
+  echoSetup();
+}
+
+void loop(void)
+{
+  // Update the echo server.
+  echoLoop();
+}
+
+/**************************************************************************/
+/*!
+    @brief  Tries to read the IP address and other connection details
+*/
+/**************************************************************************/
+bool displayConnectionDetails(void)
+{
+  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
+
+  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
+  {
+    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
+    return false;
+  }
+  else
+  {
+    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
+    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
+    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
+    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
+    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
+    Serial.println();
+    return true;
+  }
+}


Create ds18b20.ino

Create ds18b20.ino

error: pathspec 'dragino/ds18b20.ino' did not match any file(s) known to git

--- dragino/ds18b20.ino
+++ dragino/ds18b20.ino
@@ -0,0 +1,77 @@
+
+#include <Process.h>
+#include "MQTTclient.h"
+#include "DHT.h"
+#include <OneWire.h>
+#include <DallasTemperature.h>
+
+
+#define ONE_WIRE_BUS_PIN A3
+float  tempC2 = 0;
+float  tempC3 = 0;
+unsigned long time;
+
+OneWire oneWire(ONE_WIRE_BUS_PIN);
+DallasTemperature sensors(&oneWire);
+//DeviceAddress probe01 =  {0x28, 0xC7, 0xEB, 0xF0, 0x05, 0x00, 0x00, 0xEA};
+
+#define MQTT_HOST "190.97.168.236"
+#define DHTPIN A0
+//#define DHTPIN2 A1
+
+#define DHTTYPE DHT22   // DHT 22  (AM2302)
+DHT dht(DHTPIN, DHTTYPE);
+//DHT dht2(DHTPIN2, DHTTYPE);
+
+
+char message_buff[100];
+char message_buff2[100];
+char message[256];
+String id_sensor = "test4";
+
+
+float t2;
+
+
+
+void setup() {
+
+  Serial.begin(9600);
+  Bridge.begin();
+  mqtt.begin(MQTT_HOST, 1883);
+  dht.begin();
+  sensors.begin();
+  //sensors.setResolution(probe01, 10);
+
+  mqtt.subscribe("test/temp", someEvent);
+
+
+}
+
+
+void loop() {
+  float h = dht.readHumidity();
+  float t = dht.readTemperature();
+
+ sensors.requestTemperatures();
+
+ tempC2 = sensors.getTempCByIndex(0),4;
+ //tempC2 = sensors.getTempC(probe01);
+   if (millis() > (time + 20000)) {
+       time = millis();
+
+ String pubString = "" + String(t) + "," + String(tempC2) + "," + String(h) + "," + id_sensor + "";
+   pubString.toCharArray(message_buff, pubString.length()+1);
+   mqtt.publish("test/temp",message_buff );
+
+   }
+   else{
+
+  mqtt.monitor();
+   }
+
+}
+
+void someEvent(const String& topic, const String& subtopic, const String& message) {
+
+}


Added Button Control to motion gesture

Added Button Control to motion gesture

The user needs to hold the button (SW2) while moving the board.
The CC3200 needs to be held vertically with the LEDS facing the outside
world (not facing the person holding it)

(readings are not accurate all the time... >.< )

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Mastergalen/RPlayr.git/'


Update to provide datums we variable

Update to provide datums we variable

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/MitchellJThomas/medir.git/'


Adding a Nucleo thread variant of the blink sketch.

error: pathspec 'examples/Nucleo/CosaNucleoBlink/CosaNucleoBlink.ino' did not match any file(s) known to git

--- examples/Nucleo/CosaNucleoBlink/CosaNucleoBlink.ino
+++ examples/Nucleo/CosaNucleoBlink/CosaNucleoBlink.ino
@@ -0,0 +1,88 @@
+/**
+ * @file CosaNucleoBlink.ino
+ * @version 1.0
+ *
+ * @section License
+ * Copyright (C) 2014, Mikael Patel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA  02111-1307  USA
+ *
+ * @section Description
+ * Demonstration of Cosa Nucleo Threads; Blink LED with thread
+ * delay and use an additional thread to control the LED blink
+ * frequency.
+ *
+ * This file is part of the Arduino Che Cosa project.
+ */
+
+#include "Cosa/Pins.hh"
+#include "Cosa/Watchdog.hh"
+#include "Cosa/Nucleo/Thread.hh"
+
+class LED : public Nucleo::Thread {
+private:
+  OutputPin m_pin;
+  uint16_t m_delay;
+public:
+  LED(Board::DigitalPin pin) : Thread(), m_pin(pin, 1), m_delay(200) {}
+  void set_delay(uint16_t ms) { m_delay = ms; }
+  virtual void run();
+};
+
+void
+LED::run()
+{
+  m_pin.toggle();
+  delay(m_delay);
+}
+
+template <uint16_t LOW, uint16_t HIGH, uint16_t INC>
+class LEDController : public Nucleo::Thread {
+private:
+  LED* m_led;
+public:
+  LEDController(LED* led) : Thread(), m_led(led) {}
+  virtual void run();
+};
+
+template <uint16_t LOW, uint16_t HIGH, uint16_t INC>
+void
+LEDController<LOW, HIGH, INC>::run()
+{
+  for (uint16_t ms = LOW; ms < HIGH; ms += INC) {
+    m_led->set_delay(ms);
+    delay(1000);
+  }
+  for (uint16_t ms = HIGH; ms > LOW; ms -= INC) {
+    m_led->set_delay(ms);
+    delay(1000);
+  }
+}
+
+LED buildin(Board::LED);
+LEDController<20,200,20> controller(&buildin);
+
+void setup()
+{
+  Watchdog::begin();
+  Nucleo::Thread::begin(&buildin, 32);
+  Nucleo::Thread::begin(&controller, 32);
+}
+
+void loop()
+{
+  Nucleo::Thread::begin();
+}


Major rework and cleanup.

Major rework and cleanup.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/spoollord/MyOurWeather.git/'


Optimise data types

Optimise data types

You do not need an entire `int` just to store `HIGH`/`LOW`.

fatal: remote error: upload-pack: not our ref 8ea207a00107b685d119929bf0e3d4d30d8abd9d
fatal: the remote end hung up unexpectedly


Add first firmware to control motors and publish encoder state from MegaPi throught ROS

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Bobox214/Dovlo.git/'


신호처리 시뮬레이션 코드 추가

신호처리 시뮬레이션 코드 추가

Arduino

error: pathspec 'SignalProcessing/test_convolution_arduino/test_convolution_arduino.ino' did not match any file(s) known to git

--- SignalProcessing/test_convolution_arduino/test_convolution_arduino.ino
+++ SignalProcessing/test_convolution_arduino/test_convolution_arduino.ino
@@ -0,0 +1,50 @@
+void setup () {
+  Serial.begin(115200);
+
+  // test sample values from matlab documatation
+  //float u[] = {1, 0, 1};
+  //float v[] = {2, 7};
+  //float u[] = {1, 1, 1};
+  //float v[] = {1, 1, 0, 0, 0, 1, 1};
+  float u[] = {-1, 2, 3, -2, 0, 1, 2};
+  float v[] = {2, 4, -1, 1};
+  bool isSame = false;
+
+  int uLength = sizeof(u) / sizeof(float);
+  int vLength = sizeof(v) / sizeof(float);
+  int wLength = isSame ? uLength : uLength + vLength - 1 ;
+  float w[wLength] = {};
+
+  convolution(u, uLength, v, vLength, w, isSame);
+  for (int i = 0; i < wLength; i++) {
+    Serial.println(w[i]);
+  }
+}
+
+void loop() {
+}
+
+void convolution(float *u, int uLength, float *v, int vLength, float *w, bool isSame) {
+  float tmpArr[uLength + vLength - 1] = {};
+  for (int i = 0; i < uLength + vLength - 1; i++) {
+    int index = i;
+    float tmpVal = 0;
+    for (int j = 0; j < vLength; j++) {
+      if (index >= 0 && index < uLength) {
+        tmpVal += u[index] * v[j];
+      }
+      index--;
+      tmpArr[i] = tmpVal;
+    }
+  }
+  if (isSame) {
+    int start = ceil((vLength - 1) / 2.0);
+    for (int i = 0; i < uLength; i++) {
+      w[i] = tmpArr[start+i];
+    }
+  } else {
+    for (int i = 0; i < uLength + vLength - 1; i++) {
+      w[i] = tmpArr[i];
+    }
+  }
+}


Changed UziFirmware.ino to use the new EEPROMWearLevelingWriter.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/RichoM/Uzi.git/'


Added a startup check for a program stored in the EEPROM.


Finished motion sensor code for display

Finished motion sensor code for display

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/WestwoodRobotics/BEST-2015.git/'


Added minimal test sketch

Added minimal test sketch

error: pathspec 'testsuite/REV20Minimal/REV20Minimal.ino' did not match any file(s) known to git

--- testsuite/REV20Minimal/REV20Minimal.ino
+++ testsuite/REV20Minimal/REV20Minimal.ino
@@ -0,0 +1,307 @@
+/*
+The OpenTRV project licenses this file to you
+under the Apache Licence, Version 2.0 (the "Licence");
+you may not use this file except in compliance
+with the Licence. You may obtain a copy of the Licence at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the Licence is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the Licence for the
+specific language governing permissions and limitations
+under the Licence.
+
+Author(s) / Copyright (s): Deniz Erbilgin 2016
+*/
+/**
+ * Minimal REV7 config for testing power consumption.
+ * Aim is to:
+ *     - todo init GPIO pins to safe mode.
+ *     - todo init peripherals to safe low power mode.
+ *     - loop endlessly.
+ */
+
+// INCLUDES & DEFINES
+// Debug output flag
+#define DEBUG
+// REV7 / DORM1 all-in-one valve unit, secure TX.
+//#define CONFIG_DORM1
+// Get defaults for valve applications.
+#include <OTV0p2_valve_ENABLE_defaults.h>
+// All-in-one valve unit (DORM1).
+#include <OTV0p2_CONFIG_REV20.h>
+// I/O pin allocation and setup: include ahead of I/O module headers.
+#include <OTV0p2_Board_IO_Config.h>
+// OTV0p2Base Libraries
+#include <OTV0p2Base.h>
+// RadValve libraries
+#include <OTRadValve.h>
+
+
+// Debugging output
+#ifndef DEBUG
+#define DEBUG_SERIAL_PRINT(s) // Do nothing.
+#define DEBUG_SERIAL_PRINTFMT(s, format) // Do nothing.
+#define DEBUG_SERIAL_PRINT_FLASHSTRING(fs) // Do nothing.
+#define DEBUG_SERIAL_PRINTLN_FLASHSTRING(fs) // Do nothing.
+#define DEBUG_SERIAL_PRINTLN() // Do nothing.
+#define DEBUG_SERIAL_TIMESTAMP() // Do nothing.
+#else
+// Send simple string or numeric to serial port and wait for it to have been sent.
+// Make sure that Serial.begin() has been invoked, etc.
+#define DEBUG_SERIAL_PRINT(s) { OTV0P2BASE::serialPrintAndFlush(s); }
+#define DEBUG_SERIAL_PRINTFMT(s, fmt) { OTV0P2BASE::serialPrintAndFlush((s), (fmt)); }
+#define DEBUG_SERIAL_PRINT_FLASHSTRING(fs) { OTV0P2BASE::serialPrintAndFlush(F(fs)); }
+#define DEBUG_SERIAL_PRINTLN_FLASHSTRING(fs) { OTV0P2BASE::serialPrintlnAndFlush(F(fs)); }
+#define DEBUG_SERIAL_PRINTLN() { OTV0P2BASE::serialPrintlnAndFlush(); }
+// Print timestamp with no newline in format: MinutesSinceMidnight:Seconds:SubCycleTime
+extern void _debug_serial_timestamp();
+#define DEBUG_SERIAL_TIMESTAMP() _debug_serial_timestamp()
+#endif // DEBUG
+
+// OBJECTS & VARIABLES
+/**
+ * Peripherals present on REV7
+ * - Pot        Set input to Hi-Z?  +
+ * - PHT        IO_POWER_UP LOW
+ * - Encoder    IO_POWER_UP LOW
+ * - LED        Set pin HIGH?
+ * - Button     Set to INPUT
+ * - H-Bridge   Control pins HIGH, Current sense set to input.  +
+ * - SHT21      read() once.        +
+ * - RFM23B     ??                  +
+ * - XTAL       Setup and leave running?
+ * - UART       Disable
+ */
+
+/**
+ * Dummy Types
+ */
+// Placeholder class with dummy static status methods to reduce code complexity.
+typedef OTV0P2BASE::DummySensorOccupancyTracker OccupancyTracker;
+
+/**
+ * Supply Voltage instance
+ */
+// Sensor for supply (eg battery) voltage in millivolts.
+// Singleton implementation/instance.
+OTV0P2BASE::SupplyVoltageCentiVolts Supply_cV;
+
+/*
+ * Radio instance
+ */
+static constexpr bool RFM23B_allowRX = false;
+
+static constexpr uint8_t RFM23B_RX_QUEUE_SIZE = OTRFM23BLink::DEFAULT_RFM23B_RX_QUEUE_CAPACITY;
+static constexpr int8_t RFM23B_IRQ_PIN = -1;// PIN_RFM_NIRQ;
+// XXX Is it really worth having a separate primary radio in this case?
+OTRFM23BLink::OTRFM23BLink<OTV0P2BASE::V0p2_PIN_SPI_nSS, RFM23B_IRQ_PIN, RFM23B_RX_QUEUE_SIZE, RFM23B_allowRX> PrimaryRadio;//RFM23B;
+///* constexpr */ OTRadioLink::OTRadioLink &PrimaryRadio = RFM23B
+// Pick an appropriate radio config for RFM23 (if it is the primary radio).
+// Nodes talking on fast GFSK channel 0.
+static const uint8_t nPrimaryRadioChannels = 1;
+static const OTRadioLink::OTRadioChannelConfig RFM23BConfigs[nPrimaryRadioChannels] = {
+    // GFSK channel 0 full config, RX/TX, not in itself secure.
+    OTRadioLink::OTRadioChannelConfig(OTRFM23BLink::StandardRegSettingsGFSK57600, true), };
+
+/*
+ * SHT21 instance
+ */
+OTV0P2BASE::RoomTemperatureC16_SHT21 TemperatureC16; // SHT21 impl.
+
+// HUMIDITY_SENSOR_SUPPORT is defined if at least one humidity sensor has support compiled in.
+// Simple implementations can assume that the sensor will be present if defined;
+// more sophisticated implementations may wish to make run-time checks.
+// If SHT21 support is enabled at compile-time then its humidity sensor may be used at run-time.
+// Singleton implementation/instance.
+typedef OTV0P2BASE::HumiditySensorSHT21 RelHumidity_t;
+RelHumidity_t RelHumidity;
+
+/**
+ * Temp pot
+ */
+// Sensor for temperature potentiometer/dial UI control.
+// Correct for DORM1/TRV1 with embedded REV7.
+// REV7 does not drive pot from IO_POWER_UP.
+typedef OTV0P2BASE::SensorTemperaturePot<OccupancyTracker, nullptr, 48, 296, false> TempPot_t;
+TempPot_t TempPot;
+
+/**
+ * Ambient Light Sensor
+ */
+typedef OTV0P2BASE::SensorAmbientLight AmbientLight;
+// Singleton implementation/instance.
+AmbientLight AmbLight;
+
+/**
+ * Valve Actuator
+ */
+// DORM1/REV7 direct drive motor actuator.
+static constexpr bool binaryOnlyValveControl = false;
+static constexpr uint8_t m1 = MOTOR_DRIVE_ML;
+static constexpr uint8_t m2 = MOTOR_DRIVE_MR;
+typedef OTRadValve::ValveMotorDirectV1<m1, m2, MOTOR_DRIVE_MI_AIN, MOTOR_DRIVE_MC_AIN, decltype(Supply_cV), &Supply_cV, binaryOnlyValveControl> ValveDirect_t;
+// Singleton implementation/instance.
+// Suppress unnecessary activity when room dark, eg to avoid disturbance if device crashes/restarts,
+// unless recent UI use because value is being fitted/adjusted.
+ValveDirect_t ValveDirect([](){return(AmbLight.isRoomDark());});
+
+// FUNCTIONS
+
+/**
+ * Panic Functions
+ */
+// Indicate that the system is broken in an obvious way (distress flashing the main LED).
+// DOES NOT RETURN.
+// Tries to turn off most stuff safely that will benefit from doing so, but nothing too complex.
+// Tries not to use lots of energy so as to keep distress beacon running for a while.
+void panic()
+{
+    // Reset radio and go into low-power mode.
+    PrimaryRadio.panicShutdown();
+    // Power down almost everything else...
+    OTV0P2BASE::minimisePowerWithoutSleep();
+    pinMode(OTV0P2BASE::LED_HEATCALL_L, OUTPUT);
+    for( ; ; )
+    {
+        OTV0P2BASE::LED_HEATCALL_ON();
+        OTV0P2BASE::nap(WDTO_15MS);
+        OTV0P2BASE::LED_HEATCALL_OFF();
+        OTV0P2BASE::nap(WDTO_120MS);
+    }
+}
+// Panic with fixed message.
+void panic(const __FlashStringHelper *s)
+{
+    OTV0P2BASE::serialPrintlnAndFlush(); // Start new line to highlight error.  // May fail.
+    OTV0P2BASE::serialPrintAndFlush('!'); // Indicate error with leading '!' // May fail.
+    OTV0P2BASE::serialPrintlnAndFlush(s); // Print supplied detail text. // May fail.
+    panic();
+}
+
+
+/**
+ * @brief   Set pins and on-board peripherals to safe low power state.
+ */
+
+
+//========================================
+// SETUP
+//========================================
+
+// Setup routine: runs once after reset.
+// Does some limited board self-test and will panic() if anything is obviously broken.
+void setup()
+{
+    // Set appropriate low-power states, interrupts, etc, ASAP.
+    OTV0P2BASE::powerSetup();
+    // IO setup for safety, and to avoid pins floating.
+    OTV0P2BASE::IOSetup();
+
+    OTV0P2BASE::serialPrintAndFlush(F("\r\nOpenTRV: ")); // Leading CRLF to clear leading junk, eg from bootloader.
+    V0p2Base_serialPrintlnBuildVersion();
+
+    OTV0P2BASE::LED_HEATCALL_ON();
+
+    // Give plenty of time for the XTal to settle.
+    delay(1000);
+
+    // Have 32678Hz clock at least running before going any further.
+    // Check that the slow clock is running reasonably OK, and tune the fast one to it.
+    if(!::OTV0P2BASE::HWTEST::calibrateInternalOscWithExtOsc()) { panic(F("Xtal")); } // Async clock not running or can't tune.
+//    if(!::OTV0P2BASE::HWTEST::check32768HzOsc()) { panic(F("xtal")); } // Async clock not running correctly.
+
+    // Initialise the radio, if configured, ASAP because it can suck a lot of power until properly initialised.
+    PrimaryRadio.preinit(NULL);
+    // Check that the radio is correctly connected; panic if not...
+    if(!PrimaryRadio.configure(nPrimaryRadioChannels, RFM23BConfigs) || !PrimaryRadio.begin()) { panic(F("r1")); }
+
+    // Buttons should not be activated DURING boot for user-facing boards; an activated button implies a fault.
+    // Check buttons not stuck in the activated position.
+    if(fastDigitalRead(BUTTON_MODE_L) == LOW) { panic(F("b")); }
+
+    // Collect full set of environmental values before entering loop() in normal mode.
+    // This should also help ensure that sensors are properly initialised.
+
+    // No external sensors are *assumed* present if running alt main loop
+    // This may mean that the alt loop/POST will have to initialise them explicitly,
+    // and the initial seed entropy may be marginally reduced also.
+    const int cV = Supply_cV.read();
+    DEBUG_SERIAL_PRINT_FLASHSTRING("V: ");
+    DEBUG_SERIAL_PRINT(cV);
+    DEBUG_SERIAL_PRINTLN();
+    const int heat = TemperatureC16.read();
+    DEBUG_SERIAL_PRINT_FLASHSTRING("T: ");
+    DEBUG_SERIAL_PRINT(heat);
+    DEBUG_SERIAL_PRINTLN();
+    const uint8_t rh = RelHumidity.read();
+    DEBUG_SERIAL_PRINT_FLASHSTRING("RH%: ");
+    DEBUG_SERIAL_PRINT(rh);
+    DEBUG_SERIAL_PRINTLN();
+    const int light = AmbLight.read();
+    DEBUG_SERIAL_PRINT_FLASHSTRING("L: ");
+    DEBUG_SERIAL_PRINT(light);
+    DEBUG_SERIAL_PRINTLN();
+    const int tempPot = TempPot.read();
+    DEBUG_SERIAL_PRINT_FLASHSTRING("temp pot: ");
+    DEBUG_SERIAL_PRINT(tempPot);
+    DEBUG_SERIAL_PRINTLN();
+
+    ValveDirect.read();
+
+    // Initialised: turn main/heatcall UI LED off.
+    OTV0P2BASE::LED_HEATCALL_OFF();
+
+    // Do OpenTRV-specific (late) setup.
+    PrimaryRadio.listen(false);
+
+    // Long delay after everything set up to allow a non-sleep power measurement.
+    delay(10000);
+}
+
+
+//========================================
+// MAIN LOOP
+//========================================
+/**
+ * @brief   Sleep in low power mode if not sleeping.
+ */
+void loop()
+{
+    // Ensure that serial I/O is off while sleeping.
+    OTV0P2BASE::powerDownSerial();
+    // Power down most stuff (except radio for hub RX).
+    OTV0P2BASE::minimisePowerWithoutSleep();
+    // Normal long minimal-power sleep until wake-up interrupt.
+    // Rely on interrupt to force quick loop round to I/O poll.
+    OTV0P2BASE::sleepUntilInt();
+}
+
+
+
+/**
+ * @note    Power consumption figures (all in mA).
+ * Date/commit:         Device: Wake (Sleep) @ Voltage
+ * 20161111/0e6ec96     REV7:   1.5 (1.1) @ 2.5 V       REV11:  0.45 (0.03) @ 2.5 V
+ * 20161111/f2eed5e     REV7:   0.46 (0.04) @ 2.5 V
+ */
+
+/**
+ * @note    REV7 Power consumption investigation.
+ *          Figures are not overly accurate due to hot airgun changing board temp. Shouldn't make enough of a difference for our purposes.
+ * Baseline:                1.08 mA
+ * - Motor decoupling caps: 1.08 mA
+ * - Potentiometer:         1.02 mA
+ * - BAV99 Suppressors:     1.02 mA
+ * - TANT RF decoupling:    1.01 mA
+ * - Motor diodes:          1.01 mA
+ * - Op Amp:                0.99 mA
+ * - Inductor:              178 mA (I think this is due to ML+MR being held high)
+ * - H-Bridge Transistors:  0.99 mA
+ * - All decoupling:        0.98 mA
+ * - All H-Bridge resistors:0.98 mA
+ * - Encoder:               0.98 mA
+ * - Some resistors:        0.48 mA
+ */


Ready to verify on oscilloscope. Looks good on serial.

error: pathspec 'Motor' did not match any file(s) known to git
error: pathspec 'Speed/testTimerTwo/testTimerTwo.ino' did not match any file(s) known to git


Let there be light

Let there be light

error: pathspec 'robotic_arm.ino' did not match any file(s) known to git


Create barometer.ino

Create barometer.ino

error: pathspec 'Barometer/barometer.ino' did not match any file(s) known to git

--- Barometer/barometer.ino
+++ Barometer/barometer.ino
@@ -0,0 +1 @@
+barometer


Fix semi-colon … Thanks MATLAB!

Fix semi-colon … Thanks MATLAB!

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Duke-Medical-Instrumentation/InceptionTI.git/'


Test for motor using enable pins and buttons operation.

error: pathspec 'tinkering/motor/button_op_enable/button_op_enable.ino' did not match any file(s) known to git

--- tinkering/motor/button_op_enable/button_op_enable.ino
+++ tinkering/motor/button_op_enable/button_op_enable.ino
@@ -0,0 +1,60 @@
+#include <Stepper.h>
+
+#define P1 P4_5
+#define P2 P1_1
+
+const int stepsPerRevolution = 200;
+
+Stepper myStepper(stepsPerRevolution, 12,13,5,9);
+
+short forward;
+short backward;
+
+void setup() {
+  // set the speed at 60 rpm:
+  myStepper.setSpeed(60);
+
+  // initialize the serial port:
+  Serial.begin(9600);
+
+  // Enable pin pull-up for the buttons
+  pinMode(P4_5, INPUT_PULLUP);
+  pinMode(P1_1, INPUT_PULLUP);
+
+  // Set modes for enable pins
+  pinMode(18, OUTPUT);
+  pinMode(19, OUTPUT);
+}
+
+void loop() {
+
+  // Read button pins
+  forward = digitalRead(P1);
+  backward = digitalRead(P2);
+  Serial.print(forward);
+
+  // Enable or disable motor
+  if (forward == 0 || backward == 0) {
+    digitalWrite(18, HIGH);
+    digitalWrite(19, HIGH);
+  }
+  else {
+    digitalWrite(18, LOW);
+    digitalWrite(19, LOW);
+  }
+
+  // Turn motor if a button is pressed
+  if (forward == 0) {
+    myStepper.step(1);
+  }
+
+  if (backward == 0) {
+    myStepper.step(-1);
+  }
+
+  // Delay before next loop. Determines how fast the motor turns
+  delay(4);
+
+}
+
+


added weatherstation

added weatherstation

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/werar/iothome.git/'


Create mqtt_dragino_2xrele.ino

Create mqtt_dragino_2xrele.ino

error: pathspec 'dragino/mqtt_dragino_2xrele.ino' did not match any file(s) known to git

--- dragino/mqtt_dragino_2xrele.ino
+++ dragino/mqtt_dragino_2xrele.ino
@@ -0,0 +1,86 @@
+#include <Process.h>
+#include <Wire.h>
+#include <LiquidCrystal_I2C.h>
+#include "MQTTclient.h"
+
+#define I2C_ADDR  0x27
+#define En_pin    2
+#define Rw_pin    1
+#define Rs_pin    0
+#define D4_pin    4
+#define D5_pin    5
+#define D6_pin    6
+#define D7_pin    7
+#define BACKLIGHT_PIN   3
+
+int rele1 = 4;
+int rele2 = 6;
+
+#define MQTT_HOST "190.97.168.236"
+char message_buff[100];
+char message_buff2[100];
+char message[256];
+String id_sensor = "prueba12";
+
+LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin,
+                      D4_pin, D5_pin, D6_pin, D7_pin);
+
+void setup() {
+    Serial.begin(9600);
+  Bridge.begin();
+  mqtt.begin(MQTT_HOST, 1883);
+    mqtt.subscribe("/rr/temp", someEvent);
+  lcd.begin (20, 4);
+  pinMode(rele1, OUTPUT);
+  pinMode(rele2, OUTPUT);
+  digitalWrite(rele1, HIGH);
+  digitalWrite(rele2, HIGH);
+
+  // Switch on the backlight
+  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
+  lcd.setBacklight(HIGH);
+
+  // Position cursor and write some text
+  lcd.home();
+  lcd.print("RELE 1: OFF, RELE 2: OFF");
+    mqtt.publish("test/dos", "conectado!");
+}
+
+void loop() {
+
+  mqtt.monitor();
+
+}
+
+
+void someEvent(const String& topic, const String& subtopic, const String& message) {
+
+
+
+
+
+  mqtt.publish("test/dos", "Recibido_Control_D1");
+   if (message == "rele10") {
+    digitalWrite(rele1, HIGH);
+    lcd.clear();
+    lcd.print("RELE 1: ON");
+
+  }
+  else if (message == "rele11"){
+    digitalWrite(rele1, LOW);
+        lcd.clear();
+    lcd.print("RELE 1: OFF");
+
+  }
+
+ else if (message == "rele20"){
+    digitalWrite(rele2, HIGH);
+            lcd.clear();
+    lcd.print("RELE 2: ON");
+
+  }  else if (message == "rele21"){
+    digitalWrite(rele2, LOW);
+            lcd.clear();
+    lcd.print("RELE 2: OFF");
+
+  }


Renaming to adapt to ino command tool

Renaming to adapt to ino command tool

error: pathspec 'ManMachineInterface/Oscilloscope/oscillo/src/sketch.ino' did not match any file(s) known to git

--- ManMachineInterface/Oscilloscope/oscillo/src/sketch.ino
+++ ManMachineInterface/Oscilloscope/oscillo/src/sketch.ino
@@ -0,0 +1,53 @@
+/*
+  Analog input, analog output, serial output
+
+ Reads an analog input pin, maps the result to a range from 0 to 255
+ and uses the result to set the pulsewidth modulation (PWM) of an output pin.
+ Also prints the results to the serial monitor.
+
+ The circuit:
+ * potentiometer connected to analog pin 0.
+   Center pin of the potentiometer goes to the analog pin.
+   side pins of the potentiometer go to +5V and ground
+ * LED connected from digital pin 9 to ground
+
+ created 29 Dec. 2008
+ modified 9 Apr 2012
+ by Tom Igoe
+
+ This example code is in the public domain.
+
+ */
+
+// These constants won't change.  They're used to give names
+// to the pins used:
+const int analogInPin = 0;  // Analog input pin that the potentiometer is attached to
+const int analogOutPin = 9; // Analog output pin that the LED is attached to
+
+int sensorValue = 0;        // value read from the pot
+int outputValue = 0;        // value output to the PWM (analog out)
+
+void setup() {
+  // initialize serial communications at 9600 bps:
+  Serial.begin(19200);
+}
+
+void loop() {
+  // read the analog in value:
+  for (int thisPin = 0; thisPin < 6; thisPin++) {
+  sensorValue = analogRead(thisPin);
+
+  // print the results to the serial monitor:
+  //Serial.print("sensor = " );
+  Serial.print(sensorValue);
+  Serial.print(",");
+  //Serial.print("\t output = ");
+  //Serial.println(outputValue);
+  delay(2);
+  }
+   Serial.println("");
+  // wait 2 milliseconds before the next loop
+  // for the analog-to-digital converter to settle
+  // after the last reading:
+  delay(2);
+}


example code

example code

error: pathspec 'Examples/tinyscreen-spritetile-testbed/tinyscreen-spritetile-testbed.ino' did not match any file(s) known to git


Adding example sketch to demonstrate sending, receiving and link statistics.

error: pathspec 'examples/RF12_Stream_example/RF12_Stream_example.ino' did not match any file(s) known to git

--- examples/RF12_Stream_example/RF12_Stream_example.ino
+++ examples/RF12_Stream_example/RF12_Stream_example.ino
@@ -0,0 +1,163 @@
+/*
+ * Sketch to demonstrate RF12_Stream. Prints incoming
+ * data. Periodically sends data and prints statistics about the link
+ * (number of packets sent and received, and number of retries).  The
+ * firmware size is under 8kB when compiled for the ATtiny84 so it may
+ * be possible to run the sketch on the RFM12B to Pi expansion board,
+ * http://shop.openenergymonitor.com/raspberry-pi/.
+ *
+ * Copyright S R Marple, 2013.
+ * Released under MIT License, http://opensource.org/licenses/mit-license.php
+ */
+
+#include <CircBuffer.h>
+#include <AsyncDelay.h>
+#include <RF12.h>
+#include <RF12_Stream.h>
+
+
+
+#if defined(UBRRH) || defined(UBRR0H) || defined(USBCON)
+Stream &mySerial = Serial;
+#else
+// No hardware serial or USB interface
+#define USE_SW_SERIAL
+#include <SoftwareSerial.h>
+#endif
+
+
+#ifdef CALUNIUM
+// Calunium, use pin mapping for v2.0/v2.1
+#define RFM12B_CS 14
+#define RFM12B_IRQ_PIN 6
+#define RFM12B_IRQ_NUM 2
+#define LED_PIN LED_BUILTIN
+
+#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined (__AVR_ATmega328P__)
+// Jeenode mapping?
+#define RFM12B_CS 10
+#define RFM12B_IRQ_PIN 2
+#define RFM12B_IRQ_NUM 0
+#define LED_PIN LED_BUILTIN
+
+#elif defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
+// Assume pin-mapping used for Martin Harizanov's RFM2Pi board
+#define RFM12B_CS 1
+#define RFM12B_IRQ_PIN 2
+#define RFM12B_IRQ_NUM 0
+#define LED_PIN 8
+#endif
+
+#ifdef USE_SW_SERIAL
+SoftwareSerial swSerial(7, 3);
+Stream &mySerial = swSerial;
+#endif
+
+#if RAMEND >= 4096
+// eg ATmega644(P), ATmega1284(P), ATmega1280 or ATmega2560
+uint8_t rxBuffer[1024];
+uint8_t txBuffer[1024];
+
+#elif RAMEND >= 2048
+// eg ATmega328
+uint8_t rxBuffer[512];
+uint8_t txBuffer[512];
+
+#else
+// eg ATtiny84
+uint8_t rxBuffer[30];
+uint8_t txBuffer[30];
+#endif
+
+RF12_Stream rfm12b(rxBuffer, sizeof(rxBuffer),
+		   txBuffer, sizeof(txBuffer));
+
+
+unsigned long sendInterval_ms = 2000UL;
+unsigned long statsInterval_ms = 20000UL;
+
+AsyncDelay sendDelay;
+AsyncDelay statsDelay;
+#ifdef LED_PIN
+AsyncDelay activityDelay;
+#endif
+
+void setup(void)
+{
+#ifdef SS
+  pinMode(SS, OUTPUT);
+#endif
+
+#ifdef LED_PIN
+  pinMode(LED_PIN, OUTPUT);
+  digitalWrite(LED_PIN, HIGH);
+#endif
+
+#ifdef USE_SW_SERIAL
+  swSerial.begin(9600);
+#else
+  Serial.begin(9600);
+#endif
+
+  if (rfm12b.begin(RFM12B_CS, RFM12B_IRQ_PIN, RFM12B_IRQ_NUM, 1, RF12_433MHZ)) {
+    sendDelay.start(sendInterval_ms, AsyncDelay::MILLIS);
+  }
+  else
+    while (1)
+      mySerial.println("RFM12B not found");
+
+
+#ifdef LED_PIN
+  digitalWrite(LED_PIN, LOW);
+#endif
+  activityDelay.expire();
+}
+
+void loop(void)
+{
+  bool activity = false;
+
+  rfm12b.poll();
+  if (sendDelay.isExpired()) {
+    long myMillis = millis();
+
+    mySerial.print("TX: Millis is ");
+    mySerial.println(myMillis);
+    rfm12b.print("Millis is ");
+    rfm12b.println(myMillis);
+    sendDelay.start(sendInterval_ms, AsyncDelay::MILLIS);
+  }
+
+  if (rfm12b.available()) {
+    mySerial.print("RX: ");
+    while (rfm12b.available())
+      mySerial.write(char(rfm12b.read()));
+    mySerial.println();
+    activity = true;
+  }
+
+  if (statsDelay.isExpired()) {
+    mySerial.println("--");
+    mySerial.print("TX packets: ");
+    mySerial.println(RF12_Stream::txPackets);
+
+    mySerial.print("RX packets: ");
+    mySerial.println(RF12_Stream::rxPackets);
+
+    mySerial.print("Retries: ");
+    mySerial.println(RF12_Stream::retries);
+    statsDelay.start(statsInterval_ms, AsyncDelay::MILLIS);
+  }
+
+#ifdef LED_PIN
+  if (activityDelay.isExpired()) {
+    if (activity) {
+      digitalWrite(LED_PIN, HIGH);
+      activityDelay.start(250, AsyncDelay::MILLIS);
+    }
+    else
+      digitalWrite(LED_PIN, LOW);
+  }
+#endif
+}
+


Inverting value of potenciometer

Inverting value of potenciometer

error: pathspec 'device/arduino/maoAzul.ino' did not match any file(s) known to git

--- device/arduino/maoAzul.ino
+++ device/arduino/maoAzul.ino
@@ -0,0 +1,131 @@
+#include <SoftwareSerial.h>
+#include <Servo.h>
+
+#define TACOMETER 5
+#define GUIDAO A0
+#define SERVO_PIN 9
+
+Servo servoBrk;
+
+
+float TacAct = 0, TacPast = 0, Vact=0, Vpast=0, velocity = 0;
+float transicao=0;
+int Vguidao;
+
+void setup()
+{
+    /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
+    //Configurando a entrada digital
+    pinMode(TACOMETER, INPUT_PULLUP);
+
+    /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
+
+    /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
+    /* configurando o servomotor*/
+    servoBrk.attach(SERVO_PIN);
+    servoBrk.write(map(0, '0', '9', 0, 90));
+
+    /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
+
+  /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
+  // Configurando a porta serial
+  Serial.begin(9600);
+  while (!Serial) {
+    ; // Espera a porta serial conectar
+  }
+  /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
+}
+
+void loop() // run over and over
+{
+  int count = 0, cmd;
+  /* Laço principal */
+  for(;;)
+  {
+     /* Leitura de todos os sensores */
+     /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
+     /* Leitura de todos os sensores */
+
+     TacAct = digitalRead(TACOMETER); // Tacometro
+
+     Vguidao = analogRead(GUIDAO);
+
+     /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
+
+     /* Processamento de todas as informaçes */
+     /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
+  if(count < 120)
+  {
+       if((TacAct-TacPast)!=0)
+       {
+         transicao = 1;
+       }
+       else
+       {
+         transicao = 0;
+       }
+
+       Vact = 1*transicao/1 + Vact;
+       if(Vact < 0)
+         Vact = 0;
+       else if(Vact > 1000)
+         Vact = 1000;
+
+       count++;
+  }
+  else
+  {
+    velocity = Vact;
+    Vact = 0;
+    count = 0;
+  }
+     /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
+
+     /* Envio das informacoes */
+
+     switch(cmd = Serial.read())
+     {
+
+       case 'A' :
+
+       //Serial.println("mixed = ");
+       Serial.print(1023 - Vguidao);
+       Serial.print(' ');
+       Serial.println(velocity);
+
+       break;
+
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+
+
+       cmd = map(cmd, '0', '9', 0, 90); // 0 <= pot_direction <= 179
+       servoBrk.write(cmd);
+       Serial.println(cmd);
+
+       break;
+
+       default :
+
+       break;
+
+     }
+
+     /* Atualizacao das variaveis */
+     Vpast = Vact;
+     TacPast = TacAct;
+     delay(1);
+
+
+  }
+
+}
+


Added ArduinoIDE file for the sensors

Added ArduinoIDE file for the sensors

error: pathspec 'aidu_vision/Arduino_files/sensor_to_ros/sensor_to_ros.ino' did not match any file(s) known to git

--- aidu_vision/Arduino_files/sensor_to_ros/sensor_to_ros.ino
+++ aidu_vision/Arduino_files/sensor_to_ros/sensor_to_ros.ino
@@ -0,0 +1,50 @@
+/*
+ * Rosserial sensor value publisher
+ * Publishes the value of the sensor to ros
+ * Sensor types: Sharp 041SK, Sharp GP2D12 and !!NOGIETS!!
+ *
+ * Usage:
+ * Run roscore
+ * Type in terminal: rosrun rosserial_python serial_node.py /dev/ttyACM#
+ * where # is the number of the serial port the Arduino is attached to
+ * Call the topic with: rostopic echo [$SENSOR_TYPE]_sensor
+ */
+
+
+#include <ros.h>
+#include <aidu_vision/DistanceSensors.h>
+#include <math.h>
+
+ros::NodeHandle  nh;
+
+aidu_vision::DistanceSensors distance;
+ros::Publisher sensor_publisher("sensors", &distance);
+//ros::Publisher sharp12_sensor("sharp12_sensor", &distance12);
+
+int sensorpin_41 = 0; // analog pin used to connect the sharp 041SK
+int sensorpin_12 = 1; // analog pin used to connect the sharp GP2D12
+
+void setup()
+{
+  nh.initNode();
+  nh.advertise(sensor_publisher);
+  //nh.advertise(sharp12_sensor);
+}
+
+void loop()
+{
+  double sensor_value41 = analogRead(sensorpin_41);
+  //int dis41 = (1/sensor_value41) * 26874;  // oude calibratie van chris
+  int dis41 = 27205.2633 * pow(sensor_value41, -1.0183);
+  distance.Frontleft = dis41;
+
+  double sensor_value12 = analogRead(sensorpin_12);
+  int dis12 = 38161.1739 * pow(sensor_value12, -0.9298) + 2936752.6632 * pow(sensor_value12,-2.2758995196);
+  distance.Frontright = dis12;
+
+  sensor_publisher.publish( &distance );
+
+  nh.spinOnce();
+  delay(500);
+}
+


Create Maze.ino

Create Maze.ino

Maze code in the Arduino IDE for sensing low and high reflectance, using left line follower method.

error: pathspec 'Algorithm/Maze.ino' did not match any file(s) known to git

--- Algorithm/Maze.ino
+++ Algorithm/Maze.ino
@@ -0,0 +1,140 @@
+#include <QTRSensors.h>
+#include <Wire.h>
+#include <LiquidCrystal.h>
+//#include "LCD.h"
+#include <Adafruit_MotorShield.h>
+#include "utility/Adafruit_PWMServoDriver.h"
+
+LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
+
+// This example is designed for use with six QTR-1A sensors or the first six sensors of a
+// QTR-8A module.  These reflectance sensors should be connected to analog inputs 0 to 5.
+// The QTR-8A's emitter control pin (LEDON) can optionally be connected to digital pin 2,
+// or you can leave it disconnected and change the EMITTER_PIN #define below from 2 to
+// QTR_NO_EMITTER_PIN.
+
+// The setup phase of this example calibrates the sensor for ten seconds and turns on
+// the LED built in to the Arduino on pin 13 while calibration is going on.
+// During this phase, you should expose each reflectance sensor to the lightest and
+// darkest readings they will encounter.
+// For example, if you are making a line follower, you should slide the sensors across the
+// line during the calibration phase so that each sensor can get a reading of how dark the
+// line is and how light the ground is.  Improper calibration will result in poor readings.
+// If you want to skip the calibration phase, you can get the raw sensor readings
+// (analog voltage readings from 0 to 1023) by calling qtra.read(sensorValues) instead of
+// qtra.readLine(sensorValues).
+
+// The main loop of the example reads the calibrated sensor values and uses them to
+// estimate the position of a line.  You can test this by taping a piece of 3/4" black
+// electrical tape to a piece of white paper and sliding the sensor across it.  It
+// prints the sensor values to the serial monitor as numbers from 0 (maximum reflectance)
+// to 1000 (minimum reflectance) followed by the estimated location of the line as a number
+// from 0 to 5000.  1000 means the line is directly under sensor 1, 2000 means directly
+// under sensor 2, etc.  0 means the line is directly under sensor 0 or was last seen by
+// sensor 0 before being lost.  5000 means the line is directly under sensor 5 or was
+// last seen by sensor 5 before being lost.
+
+#define NUM_SENSORS             3  // number of sensors used
+#define NUM_SAMPLES_PER_SENSOR  4  // average 4 analog samples per sensor reading
+#define EMITTER_PIN             2  // emitter is controlled by digital pin 2
+
+// sensors 0 through 5 are connected to analog inputs 0 through 5, respectively
+QTRSensorsAnalog qtra((unsigned char[]) {0, 1, 2, 3, 4, 5},
+  NUM_SENSORS, NUM_SAMPLES_PER_SENSOR, EMITTER_PIN);
+unsigned int sensorValues[NUM_SENSORS];
+
+#define FRONT    sensorValues[1]
+#define LEFT     sensorValues[0]
+#define RIGHT    sensorValues[2]
+
+// Create the motor shield object with the default I2C address
+Adafruit_MotorShield AFMS = Adafruit_MotorShield();
+// Or, create it with a different I2C address (say for stacking)
+// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);
+
+// Select which 'port' M1, M2, M3 or M4. In this case, M1
+Adafruit_DCMotor *leftMotor = AFMS.getMotor(1);
+// You can also make another motor on port M2
+Adafruit_DCMotor *rightMotor = AFMS.getMotor(2);
+
+void setup() {
+    Serial.begin(9600);           // set up Serial library at 9600 bps
+ // Serial.println("Adafruit Motorshield v2 - DC Motor test!");
+
+  AFMS.begin();  // create with the default frequency 1.6KHz
+  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz
+
+  delay(500);
+  pinMode(13, OUTPUT);
+  digitalWrite(13, HIGH);    // turn on Arduino's LED to indicate we are in calibration mode
+  // read raw sensor values
+  qtra.read(sensorValues);
+
+  // print the sensor values as numbers from 0 to 1023, where 0 means maximum reflectance and
+  // 1023 means minimum reflectance
+  for (unsigned char i = 0; i < NUM_SENSORS; i++)
+  {
+    Serial.print(sensorValues[i]);
+    Serial.print('\t'); // tab to format the raw data into columns in the Serial monitor
+  }
+  Serial.println();
+
+  delay(250);
+
+  /*for (int i = 0; i < 400; i++)  // make the calibration take about 10 seconds
+  {
+    qtra.calibrate();       // reads all sensors 10 times at 2.5 ms per six sensors (i.e. ~25 ms per call)
+  }*/
+  digitalWrite(13, LOW);     // turn off Arduino's LED to indicate we are through with calibration
+
+}
+
+void loop() {
+    // read calibrated sensor values and obtain a measure of the line position from 0 to 5000
+  // To get raw sensor values, call:
+    //qtra.read(sensorValues); //instead of unsigned int position = qtra.readLine(sensorValues);
+  unsigned int position = qtra.readLine(sensorValues);
+
+  // print the sensor values as numbers from 0 to 1000, where 0 means maximum reflectance and
+  // 1000 means minimum reflectance, followed by the line position
+ /*for (unsigned char i = 0; i < NUM_SENSORS; i++)
+  {
+    Serial.print(sensorValues[i]);
+    Serial.print('\t');
+  }*/
+
+  uint8_t i;
+
+
+ // if all three sensors see very low reflectance, take some appropriate action for this
+  // situation.
+  if (LEFT < 750 && FRONT < 750 && RIGHT < 750)
+  {
+    rightMotor->run(BRAKE);
+    leftMotor->run(BRAKE);
+    // do something.  Maybe this means we're at the edge of a course or about to fall off
+    // a table, in which case, we might want to stop moving, back up, and turn around.
+    return;
+  }
+
+  // compute our "error" from the line position.  We will make it so that the error is zero
+  // when the middle sensor is over the line, because this is our goal.  Error will range from
+  // -1000 to +1000.  If we have sensor 0 on the left and sensor 2 on the right,  a reading of
+  // -1000 means that we see the line on the left and a reading of +1000 means we see the
+  // line on the right.
+  int error = position - 1000;
+
+  int leftMotorSpeed = 100;
+  int rightMotorSpeed = 100;
+  if (error < -500) { // the line is on the left
+    rightMotor->run(FORWARD);
+    leftMotor->run(FORWARD);  // turn left
+  }
+  else  // the line is on the right
+    rightMotorSpeed = 0;  // turn right
+// set motor speeds using the two motor speed variables above
+}
+
+
+
+


cc3000 echo example

cc3000 echo example

error: pathspec 'examples/skynetim_echo_cc3000/skynetim_echo_cc3000.ino' did not match any file(s) known to git

--- examples/skynetim_echo_cc3000/skynetim_echo_cc3000.ino
+++ examples/skynetim_echo_cc3000/skynetim_echo_cc3000.ino
@@ -0,0 +1,142 @@
+/*
+ *                SSSSS  kk                            tt
+ *               SS      kk  kk yy   yy nn nnn    eee  tt
+ *                SSSSS  kkkkk  yy   yy nnn  nn ee   e tttt
+ *                    SS kk kk   yyyyyy nn   nn eeeee  tt
+ *                SSSSS  kk  kk      yy nn   nn  eeeee  tttt
+ *                               yyyyy
+ *
+ * SkynetClient for http://skynet.im, OPEN COMMUNICATIONS NETWORK & API FOR
+ * THE INTERNET OF THINGS.
+ *
+ * This sketch parses any messages it receives and echos them back to the
+ * sender.
+ *
+ * This sketch requires a port of the Adafruit CC3000 firmare library. Until
+ * Adafruit accepts it, delete theirs and grab ours at:
+ * https://github.com/jacobrosenthal/Adafruit_CC3000_Library/tree/feature/inherit-client
+ *
+ * Also requires the ArduinoJsonParser
+ * https://github.com/bblanchon/ArduinoJsonParser
+ *
+ * You will notice we're using F() in Serial.print. It is covered briefly on
+ * the arduino print page but it means we can store our strings in program
+ * memory instead of in ram.
+ *
+ * You can turn on debugging within SkynetClient.h by uncommenting
+ * #define SKYNETCLIENT_DEBUG but note this takes up a ton of program space
+ * which means you'll probably have to debug on a Mega
+ */
+
+#include <EEPROM.h>
+#include <Adafruit_CC3000.h>
+#include <ccspi.h>
+#include <string.h>
+#include "utility/debug.h"
+#include "SPI.h"
+#include "SkynetClient.h"
+#include <JsonParser.h>
+
+
+// These are the interrupt and control pins
+#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
+// These can be any two pins
+#define ADAFRUIT_CC3000_VBAT  5
+#define ADAFRUIT_CC3000_CS    10
+// Use hardware SPI for the remaining pins
+// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
+Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
+                                         SPI_CLOCK_DIVIDER); // you can change this clock speed
+
+#define WLAN_SSID       "myNetwork"           // cannot be longer than 32 characters!
+#define WLAN_PASS       "myPassword"
+// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
+#define WLAN_SECURITY   WLAN_SEC_WPA2
+
+#define IDLE_TIMEOUT_MS  3000      // Amount of time to wait (in milliseconds) with no data
+                                   // received before closing the connection.  If you know the server
+                                   // you're accessing is quick to respond, you can reduce this value.
+
+#define HOSTNAME      "skynet.im"
+#define PORT          80
+
+Adafruit_CC3000_Client client = Adafruit_CC3000_Client();
+
+SkynetClient skynetclient(client);
+
+void setup()
+{
+  Serial.begin(9600);
+
+  /* Initialise the module */
+  Serial.println(F("\nInitializing..."));
+  if (!cc3000.begin())
+  {
+    Serial.println(F("Couldn't begin()! Check your wiring?"));
+    while(1);
+  }
+
+  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
+    Serial.println(F("Failed!"));
+    while(1);
+  }
+
+  Serial.println(F("Connected!"));
+
+  /* Wait for DHCP to complete */
+  Serial.println(F("Request DHCP"));
+  while (!cc3000.checkDHCP())
+  {
+    delay(100); // ToDo: Insert a DHCP timeout!
+  }
+
+  skynetclient.setMessageDelegate(onMessage);
+
+}
+
+void onMessage(const char * const data) {
+
+  JsonParser<16> parser;
+
+  Serial.print("Parse ");
+  Serial.println(data);
+
+  JsonHashTable hashTable = parser.parseHashTable((char*)data);
+
+  if (!hashTable.success())
+  {
+      Serial.println("JsonParser.parseHashTable() failed");
+      return;
+  }
+
+  char* payload = hashTable.getString("payload");
+  Serial.print("payload=");
+  Serial.println(payload);
+
+  char* fromUuid = hashTable.getString("fromUuid");
+  Serial.print("fromUuid=");
+  Serial.println(fromUuid);
+
+  skynetclient.sendMessage(fromUuid, payload);
+}
+
+void loop() {
+  while(!skynetclient.monitor()){
+    bool skynetStatus = false;
+    do {
+      skynetStatus = skynetclient.connect(HOSTNAME, PORT);
+    } while (!skynetStatus);
+
+    Serial.println(F("Connected!"));
+
+    char uuid[UUIDSIZE];
+
+    skynetclient.getUuid(uuid);
+    Serial.print(F("uuid: "));
+    Serial.println(uuid);
+
+    skynetclient.getToken(uuid);
+    Serial.print(F("token: "));
+    Serial.println(uuid);
+  }
+}


IR Break Beam Sensor

IR Break Beam Sensor

error: pathspec '_28-attiny85-nrf24-3pin-ir/_28-attiny85-nrf24-3pin-ir.ino' did not match any file(s) known to git

--- _28-attiny85-nrf24-3pin-ir/_28-attiny85-nrf24-3pin-ir.ino
+++ _28-attiny85-nrf24-3pin-ir/_28-attiny85-nrf24-3pin-ir.ino
@@ -0,0 +1,176 @@
+// 5pin
+/* 24l01    85
+   1  gnd   4
+   2  vcc   8
+   3  ce    1
+   4  csn   3
+   5  sck   7
+   6  mosi  6
+   7  miso  5
+*/
+
+// 3pin
+/* 24l01    85
+   1  gnd   4
+   2  vcc   8
+   3  ce    x
+   4  csn   x
+   5  sck   7
+   6  mosi  6
+   7  miso  5
+*/
+#include <LowPower.h>
+#include <avr/wdt.h>
+#include <avr/interrupt.h>
+#include <avr/sleep.h>
+#include <avr/pgmspace.h>
+#include <Average.h>
+#include <nRF24L01.h>
+#include <RF24.h>
+
+#define adc_disable() (ADCSRA &= ~(1<<ADEN)) // disable ADC
+#define adc_enable()  (ADCSRA |=  (1<<ADEN)) // re-enable ADC
+
+//#define _TEST
+#define _DIGITAL
+#define _3PIN
+//#define _5PIN
+
+#ifdef _3PIN
+// 3pin
+#define CE_PIN 3
+#define CSN_PIN 3
+#else
+// 5pin
+#define CE_PIN 5
+#define CSN_PIN 4
+#endif
+
+#define DEVICE_ID 65
+#define CHANNEL 100
+
+const uint64_t pipes[2] = { 0xFFFFFFFFFFLL, 0xCCCCCCCCCCLL };
+
+typedef struct {
+  uint32_t _salt;
+  uint16_t volt;
+  int16_t data1;
+  int16_t data2;
+  uint8_t devid;
+} data;
+
+data payload;
+
+RF24 radio(CE_PIN, CSN_PIN);
+
+#define IRENPIN 4 // p3 / A2
+#define DATA1PIN A3 // p2
+
+Average<float> ave(2);
+
+void setup() {
+  delay(20);
+  adc_disable();
+  unsigned long startmilis = millis();
+
+#ifdef _DIGITAL
+  pinMode(DATA1PIN, INPUT_PULLUP);
+#endif
+  pinMode(IRENPIN, OUTPUT);
+  digitalWrite(IRENPIN, LOW);
+
+  radio.begin();
+  radio.setChannel(CHANNEL);
+  radio.setPALevel(RF24_PA_LOW);
+  radio.setDataRate(RF24_250KBPS);
+  //radio.setAutoAck(1);
+  radio.setRetries(15, 15);
+  radio.setPayloadSize(11);
+  radio.openWritingPipe(pipes[0]);
+  radio.stopListening();
+  //radio.powerDown();
+
+  unsigned long stopmilis = millis();
+  payload.data2 = ( stopmilis - startmilis ) * 10 ;
+
+  payload._salt = 0;
+  payload.devid = DEVICE_ID;
+
+}
+
+void loop() {
+  unsigned long startmilis = millis();
+  payload._salt++;
+  digitalWrite(IRENPIN, HIGH);
+  payload.volt = readVcc();
+#ifdef _DIGITAL
+  //delay(3);
+  payload.data1  = digitalRead(DATA1PIN) * 10 ;
+#else
+  //delay(3);
+  payload.data1  = readData1() * 10;
+#endif
+  digitalWrite(IRENPIN, LOW);
+
+  radio.powerUp();
+  radio.write(&payload , sizeof(payload));
+  radio.powerDown();
+
+  unsigned long stopmilis = millis();
+
+  payload.data2 = ( stopmilis - startmilis ) * 10 ;
+
+  if ((millis() - startmilis) > 1000) {
+    sleep();
+    return;
+  }
+
+  sleep();
+
+}
+
+void sleep() {
+#ifdef _TEST
+  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
+#else
+  for (int i = 0; i < 7; i++) {
+    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
+  }
+  LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
+#endif
+}
+
+int readVcc() {
+  adc_enable();
+  ADMUX = _BV(MUX3) | _BV(MUX2);
+
+  delay(2);
+  ADCSRA |= _BV(ADSC); // Start conversion
+  while (bit_is_set(ADCSRA, ADSC)); // measuring
+
+  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH
+  uint8_t high = ADCH; // unlocks both
+
+  long result = (high << 8) | low;
+
+  //result = 1126400L / result; // Calculate Vcc (in mV);
+  result = 1074835L / result;
+
+  //Disable ADC
+  adc_disable();
+
+  return (int)result; // Vcc in millivolts
+}
+
+int16_t readData1() {
+
+  adc_enable();
+  delay(2);
+  for (int k = 0; k < 2; k = k + 1) {
+    uint16_t value = analogRead(DATA1PIN);
+    ave.push(value);
+    delay(5);
+  }
+  return ave.mean();
+  adc_disable();
+}


fix typo

fix typo

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/wsnook/sandbox.git/'


Added initial version of arduino code

Added initial version of arduino code

error: pathspec 'RfidShelf.ino' did not match any file(s) known to git

--- RfidShelf.ino
+++ RfidShelf.ino
@@ -0,0 +1,242 @@
+/**
+
+*/
+
+#include <SPI.h>
+#include <MFRC522.h>
+
+//Add the SdFat Libraries
+#include <SdFat.h>
+#include <SdFatUtil.h>
+
+/*
+   For the RFID to work while MP3 plays, you have to change
+   #define USE_MP3_REFILL_MEANS USE_MP3_INTx
+   to
+   #define USE_MP3_REFILL_MEANS USE_MP3_Polled
+   in SFEMP3Shield.h
+*/
+#include <SFEMP3Shield.h>
+
+#define RST_PIN         5           // Configurable, see typical pin layout above
+#define SS_PIN          10          // Configurable, see typical pin layout above
+
+MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
+
+MFRC522::MIFARE_Key key;
+
+// Init array that will store new NUID
+byte nuidPICC[4];
+
+
+// Below is not needed if interrupt driven. Safe to remove if not using.
+#if defined(USE_MP3_REFILL_MEANS) && USE_MP3_REFILL_MEANS == USE_MP3_Timer1
+#include <TimerOne.h>
+#elif defined(USE_MP3_REFILL_MEANS) && USE_MP3_REFILL_MEANS == USE_MP3_SimpleTimer
+#include <SimpleTimer.h>
+#endif
+
+SdFat sd;
+
+SFEMP3Shield MP3player;
+
+void setup() {
+  Serial.begin(115200);
+  while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
+
+  //Initialize the SdCard.
+  if (!sd.begin(SD_SEL, SPI_FULL_SPEED)) sd.initErrorHalt();
+  // depending upon your SdCard environment, SPI_HAVE_SPEED may work better.
+  if (!sd.chdir("/")) sd.errorHalt("sd.chdir");
+
+  //Initialize the MP3 Player Shield
+  uint8_t result = MP3player.begin();
+  //check result, see readme for error codes.
+  if (result != 0) {
+    Serial.print(F("Error code: "));
+    Serial.print(result);
+    Serial.println(F(" when trying to start MP3 player"));
+    if ( result == 6 ) {
+      Serial.println(F("Warning: patch file not found, skipping.")); // can be removed for space, if needed.
+      Serial.println(F("Use the \"d\" command to verify SdCard can be read")); // can be removed for space, if needed.
+    }
+  }
+
+  SPI.begin();        // Init SPI bus
+  mfrc522.PCD_Init(); // Init MFRC522 card
+
+  for (byte i = 0; i < 6; i++) {
+    key.keyByte[i] = 0xFF;
+  }
+
+  Serial.print(F("Using rfid key (for A and B):"));
+  dump_byte_array(key.keyByte, MFRC522::MF_KEY_SIZE);
+  Serial.println();
+}
+
+/**
+   Main loop.
+*/
+void loop() {
+#if defined(USE_MP3_REFILL_MEANS) \
+      && ( (USE_MP3_REFILL_MEANS == USE_MP3_SimpleTimer) \
+      ||   (USE_MP3_REFILL_MEANS == USE_MP3_Polled)      )
+
+  MP3player.available();
+#endif
+
+  // Look for new cards
+  if ( ! mfrc522.PICC_IsNewCardPresent())
+    return;
+
+  // Select one of the cards
+  if ( ! mfrc522.PICC_ReadCardSerial())
+    return;
+
+  // Show some details of the PICC (that is: the tag/card)
+  Serial.print(F("Card UID:"));
+  dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
+  Serial.println();
+  Serial.print(F("PICC type: "));
+  MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
+  Serial.println(mfrc522.PICC_GetTypeName(piccType));
+
+  // Check for compatibility
+  if ( piccType != MFRC522::PICC_TYPE_MIFARE_1K ) {
+    Serial.println(F("Unsupported card."));
+    return;
+  }
+
+  if (mfrc522.uid.uidByte[0] == nuidPICC[0] &&
+      mfrc522.uid.uidByte[1] == nuidPICC[1] &&
+      mfrc522.uid.uidByte[2] == nuidPICC[2] &&
+      mfrc522.uid.uidByte[3] == nuidPICC[3] ) {
+    Serial.println(F("Card already read"));
+    return;
+  }
+
+  // Store NUID into nuidPICC array
+  for (byte i = 0; i < 4; i++) {
+    nuidPICC[i] = mfrc522.uid.uidByte[i];
+  }
+
+  char folder[17];
+  readBlock(1, 0, folder);
+  Serial.print(F("Folder on rfid: "));
+  Serial.println(folder);
+  playFolder(folder);
+
+  delay(100);
+}
+
+void readBlock(uint8_t sector, uint8_t relativeBlock, char *outputBuffer) {
+  if (relativeBlock > 3) {
+    Serial.println(F("Invalid block number"));
+    return;
+  }
+
+  // Block 4 is trailer block
+  byte trailerBlock   = (sector * 4) + 3;
+  byte absoluteBlock = (sector * 4) + relativeBlock;
+  MFRC522::StatusCode status;
+
+  // Authenticate using key A
+  Serial.println(F("Authenticating using key A..."));
+  status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid));
+  if (status != MFRC522::STATUS_OK) {
+    Serial.print(F("PCD_Authenticate() failed: "));
+    Serial.println(mfrc522.GetStatusCodeName(status));
+    return;
+  }
+
+  // Read data from the block
+  Serial.print(F("Reading data from block "));
+  Serial.print(absoluteBlock);
+  Serial.println(F(" ..."));
+  byte buffer[18];
+  byte bufferSize = sizeof(buffer);
+  status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(absoluteBlock, buffer, &bufferSize);
+  if (status != MFRC522::STATUS_OK) {
+    Serial.print(F("MIFARE_Read() failed: "));
+    Serial.println(mfrc522.GetStatusCodeName(status));
+  }
+  Serial.print(F("Data in block ")); Serial.print(absoluteBlock); Serial.println(F(":"));
+  dump_byte_array(buffer, 16);
+  Serial.println();
+  Serial.println();
+
+
+  // Halt PICC
+  mfrc522.PICC_HaltA();
+  // Stop encryption on PCD
+  mfrc522.PCD_StopCrypto1();
+
+  for (byte i = 0; i < bufferSize; i++) {
+    outputBuffer[i] = buffer[i];
+  }
+  outputBuffer[bufferSize] = '\0';
+
+}
+
+/**
+   Helper routine to dump a byte array as hex values to Serial.
+*/
+void dump_byte_array(byte *buffer, byte bufferSize) {
+  for (byte i = 0; i < bufferSize; i++) {
+    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
+    Serial.print(buffer[i], HEX);
+  }
+}
+
+void playFolder(char *folder) {
+  Serial.println(F("Music Files found:"));
+  SdFile file;
+  char filename[20];
+  sd.chdir(folder, true);
+  while (file.openNext(sd.vwd(), O_READ))
+  {
+    file.getFilename(filename);
+    if ( isFnMusic(filename) ) {
+      MP3player.stopTrack();
+      uint8_t result = MP3player.playMP3(filename);
+
+      //check result, see readme for error codes.
+      if (result != 0) {
+        Serial.print(F("Error code: "));
+        Serial.print(result);
+        Serial.println(F(" when trying to play track"));
+      } else {
+
+        Serial.println(F("Playing:"));
+
+        char title[30]; // buffer to contain the extract the Title from the current filehandles
+        char artist[30]; // buffer to contain the extract the artist name from the current filehandles
+        char album[30]; // buffer to contain the extract the album name from the current filehandles
+
+        //we can get track info by using the following functions and arguments
+        //the functions will extract the requested information, and put it in the array we pass in
+        MP3player.trackTitle((char*)&title);
+        MP3player.trackArtist((char*)&artist);
+        MP3player.trackAlbum((char*)&album);
+
+        //print out the arrays of track information
+        Serial.write((byte*)&title, 30);
+        Serial.println();
+        Serial.print(F("by:  "));
+        Serial.write((byte*)&artist, 30);
+        Serial.println();
+        Serial.print(F("Album:  "));
+        Serial.write((byte*)&album, 30);
+        Serial.println();
+      }
+      file.close();
+      return;
+    } else {
+      Serial.print(F("Not a music file: "));
+      Serial.println(filename);
+    }
+    file.close();
+  }
+
+}
+


Init: Arduino Code Eva

Init: Arduino Code Eva

for Agent Eva

error: pathspec 'AgenteEva/AgenteEva.ino' did not match any file(s) known to git

--- AgenteEva/AgenteEva.ino
+++ AgenteEva/AgenteEva.ino
@@ -0,0 +1,151 @@
+/*
+   Author: Jorge Rolando Encinas
+   Grupo: 10
+   Materia: Agentes Inteligentes
+*/
+
+#include <SparkFun_TB6612.h>
+#include <Ultrasonic.h>
+#include <Clamp.h>
+
+
+// these constants are used to allow you to make your motor configuration
+// line up with function names like forward.  Value can be 1 or -1
+const int offsetA = 1;
+const int offsetB = 1;
+
+// Pins for all inputs, keep in mind the PWM defines must be on PWM pins
+#define AIN1 2
+#define BIN1 7
+#define AIN2 4
+#define BIN2 8
+#define PWMA 5
+#define PWMB 6
+#define STBY 9
+
+// Pins for RPM
+#define encoderLeft       A0  //    motor left encoder
+#define encoderRight      A1  //    motor right encoder
+
+Motor motor1(AIN1, AIN2, PWMA, offsetA, STBY);
+Motor motor2(BIN1, BIN2, PWMB, offsetB, STBY);
+
+Ultrasonic ultrasonic(12, 13);
+
+Clamp clamp;
+static int serialMsg = 0;
+int pinza = 0;
+
+// vars for setup encoders for angles
+int previousDigitalLeft = digitalRead(encoderLeft);
+int previousDigitalRight = digitalRead(encoderRight);
+int digitalLeft;
+int digitalRight;
+// vars for angle events
+int encoderCountLeft = 0;
+int encoderCountRight = 0;
+int speedLeft = 0;
+int speedRight = 0;
+int pointsLeft = 0;
+int pointsRight = 0;
+// end of vars of angles
+String report;
+
+void setup() {
+  Serial.begin(38400);
+  clamp.attach(10);
+  motor1.brake();
+  motor2.brake();
+  Serial.print("$I,OK");
+}
+
+void loop() {
+  updateEventListener();
+  updateAngle();
+  updateClamp();
+}
+
+void updateAngle(){
+  digitalLeft = digitalRead(encoderLeft);
+  if (digitalLeft != previousDigitalLeft) {
+    encoderCountLeft++;
+    previousDigitalLeft = digitalLeft;
+    Serial.print("$L,");
+    Serial.println(encoderCountLeft);
+  }
+  digitalRight = digitalRead(encoderRight);
+  if (digitalRight != previousDigitalRight) {
+    encoderCountRight++;
+    previousDigitalRight = digitalRight;
+    Serial.print("$R,");
+    Serial.println(encoderCountRight);
+  }
+  if (encoderCountLeft < pointsLeft) //40 es
+    motor1.drive(speedLeft);
+  else
+    motor1.brake();
+  if (encoderCountRight < pointsRight) //40 es
+    motor2.drive(speedRight);
+  else
+    motor2.brake();
+}
+
+void updateClamp() {
+  if (pinza == 0)
+    clamp.setValue(100);
+  else
+    clamp.setValue(0);
+  //  clamp.setValue(1*100);
+}
+
+void example2() {
+  motor1.drive(30, 1000);
+  motor1.brake();
+  motor1.drive(-30, 1000);
+  motor1.brake();
+  delay(1000);
+}
+
+void updateUltrasonic() {
+  Serial.print("$U,");
+  Serial.println(ultrasonic.distanceRead());
+}
+
+void updateEventListener() {
+  if (Serial.available() > 0) {
+    delay(4);
+    serialMsg = Serial.read(); //$
+    if (serialMsg == '$') {
+      serialMsg = Serial.read();
+      switch (serialMsg) {
+        Serial.read();
+        case 'A': // Angulos o avances
+          encoderCountLeft = 0;
+          speedLeft = Serial.parseInt() * 255/100;
+          Serial.read(); // ','
+          pointsLeft = Serial.parseInt();
+          encoderCountRight = 0;
+          speedRight = Serial.parseInt() * 255/100;
+          Serial.read(); // ','
+          pointsRight = Serial.parseInt();
+          break;
+        case 'P': // Pinza
+          pinza = Serial.parseInt();
+          break;
+        case 'U': // Ultrasonic
+          updateUltrasonic();
+          break;
+        case 'e': // Test
+          break;
+        default:
+          Serial.print("No case found: '");
+          Serial.print(char(serialMsg));
+          Serial.println("'");
+          break;
+      }
+    }
+  } else {
+    ;//updateUltrasonic();
+  }
+}
+


Return to a common shift

Return to a common shift

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/mvines/futboard.git/'


crank the current down a bit - might be better

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/trinamic/T-Bone.git/'


Added required println

Added required println

error: pathspec 'BitBangingMpu6050/Right' did not match any file(s) known to git
error: pathspec 'Hand' did not match any file(s) known to git
error: pathspec 'Arduino' did not match any file(s) known to git
error: pathspec 'Code.ino' did not match any file(s) known to git


Fix merge conflicts, update log statements

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/onordbo/mood-cloud.git/'


Initial version

Initial version

Reports moisture level, battery percentage and battery voltage.

error: pathspec 'moisture.ino' did not match any file(s) known to git

--- moisture.ino
+++ moisture.ino
@@ -0,0 +1,69 @@
+#include <SPI.h>
+#include <MySensor.h>
+
+#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
+
+#define CHILD_ID_MOISTURE 0
+#define CHILD_ID_BATTERY 1
+#define SENSOR_ANALOG_PIN 0
+#define SENSOR_POWER_PIN 8
+#define SLEEP_TIME 300000 // Sleep time between reads (in milliseconds)
+#define STABILIZATION_TIME 500 // Let the sensor stabilize before reading
+#define BATTERY_FULL 3700 // 3,700 millivolts
+#define BATTERY_ZERO 1700 // 1,700 millivolts
+
+MySensor gw;
+MyMessage msg(CHILD_ID_MOISTURE, V_HUM);
+MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE);
+
+void setup()
+{
+  pinMode(SENSOR_POWER_PIN, OUTPUT);
+  gw.begin();
+
+  gw.sendSketchInfo("Plant moisture w bat", "1.1");
+
+  gw.present(CHILD_ID_MOISTURE, S_HUM);
+  delay(250);
+  gw.present(CHILD_ID_BATTERY, S_CUSTOM);
+}
+
+void loop()
+{
+  digitalWrite(SENSOR_POWER_PIN, HIGH); // Power on the sensor
+  gw.sleep(STABILIZATION_TIME);
+  int moistureLevel = (1023 - analogRead(SENSOR_ANALOG_PIN)) / 10.23;
+  digitalWrite(SENSOR_POWER_PIN, LOW);
+  gw.send(msg.set(moistureLevel));
+  long voltage = readVcc();
+  gw.send(voltage_msg.set(voltage / 1000.0, 3)); // redVcc returns millivolts and set wants volts and how many decimals (3 in our case)
+  gw.sendBatteryLevel(round((voltage - BATTERY_ZERO) * 100.0 / (BATTERY_FULL - BATTERY_ZERO)));
+  gw.sleep(SLEEP_TIME);
+}
+
+long readVcc() {
+  // From http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
+  // Read 1.1V reference against AVcc
+  // set the reference to Vcc and the measurement to the internal 1.1V reference
+#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
+  ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
+#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
+  ADMUX = _BV(MUX5) | _BV(MUX0);
+#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
+  ADMUX = _BV(MUX3) | _BV(MUX2);
+#else
+  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
+#endif
+
+  delay(2); // Wait for Vref to settle
+  ADCSRA |= _BV(ADSC); // Start conversion
+  while (bit_is_set(ADCSRA, ADSC)); // measuring
+
+  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH
+  uint8_t high = ADCH; // unlocks both
+
+  long result = (high << 8) | low;
+
+  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
+  return result; // Vcc in millivolts
+}


Still working on PID.

Still working on PID.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/FirstBuild/pizzaduino.git/'


button press auto

button press auto

error: pathspec 'buttonPressRemoteAutoClose/buttonPressRemoteAutoClose.ino' did not match any file(s) known to git

--- buttonPressRemoteAutoClose/buttonPressRemoteAutoClose.ino
+++ buttonPressRemoteAutoClose/buttonPressRemoteAutoClose.ino
@@ -0,0 +1,134 @@
+
+int inPin = 7;  // the pin number for input (for me a push button)
+int onPinA = 8; // Pin for controlling the remote
+int offPinA = 9;
+int ledPin = 13;
+
+int current;         // Current state of the button
+                     // (LOW is pressed b/c i'm using the pullup resistors)
+long millis_held;    // How long the button was held (milliseconds)
+long secs_held;      // How long the button was held (seconds)
+long prev_secs_held; // How long the button was held in the previous check
+byte previous = HIGH;
+unsigned long firstTime; // how long since the button was first pressed
+
+void setup() {
+  Serial.begin(9600);         // Use serial for debugging
+
+  pinMode(ledPin, OUTPUT);
+  pinMode(onPinA, OUTPUT);
+  pinMode(offPinA, OUTPUT);
+
+
+  digitalWrite(onPinA, HIGH);  //
+  digitalWrite(offPinA, LOW);  // Transistor should be low
+  digitalWrite(inPin, HIGH);  //
+}
+
+void loop() {
+  current = digitalRead(inPin);
+  digitalWrite(pinnum, HIGH);
+  // if the button state changes to pressed, remember the start time
+  if (current == LOW && previous == HIGH && (millis() - firstTime) > 200) {
+    firstTime = millis();
+  }
+
+  millis_held = (millis() - firstTime);
+  secs_held = millis_held / 1000;
+
+  // This if statement is a basic debouncing tool, the button must be pushed for at least
+  // 100 milliseconds in a row for it to be considered as a push.
+  if (millis_held > 50 && secs_held < 6 ) {
+
+    if (current == LOW && secs_held > prev_secs_held) {
+      ledblink(1, 50, ledPin); // Each second the button is held blink the indicator led
+    }
+
+    // check if the button was released since we last checked
+    if (current == HIGH && previous == LOW) {
+      // HERE YOU WOULD ADD VARIOUS ACTIONS AND TIMES FOR YOUR OWN CODE
+      // ===============================================================================
+
+      // Button pressed for less than 6 seconds, turn on.
+      if (secs_held < 6) {
+        Serial.print("Short Press: ");
+        Serial.print(secs_held);
+        Serial.print("   Milliseconds held: ");
+        Serial.println(millis_held);
+        //Turn on sockets
+        turnSocketsOn();
+      }
+    }
+
+      // ===============================================================================
+  } else if (secs_held >= 6) {
+      // Button held for more than 6 seconds, turn off.
+      Serial.print("Long Press: ");
+      Serial.print(secs_held);
+      Serial.print("   Milliseconds held: ");
+      Serial.println(millis_held);
+      //Turn off sockets
+      turnSocketsOff();
+  }
+
+  previous = current;
+  prev_secs_held = secs_held;
+}
+
+// Just a simple helper function to blink an led in various patterns
+void ledblink(int times, int lengthms, int pinnum){
+  for (int x=0; x<times;x++) {
+    digitalWrite(pinnum, LOW);
+    delay (lengthms);
+    digitalWrite(pinnum, HIGH);
+    delay(lengthms);
+  }
+}
+
+//Function to send a radio signal to turn sockets on
+void turnSocketsOn() {
+  // For RPi parsing
+  Serial.println("status : 1");
+  //  delay
+  delay(2000);
+  Serial.println("Turning sockets on: ");
+  //  turn on 3 times
+  digitalWrite(onPinA, LOW);
+  delay(1000);
+  digitalWrite(onPinA, HIGH);
+  delay(1000);
+
+  digitalWrite(onPinA, LOW);
+  delay(1000);
+  digitalWrite(onPinA, HIGH);
+  delay(1000);
+
+  digitalWrite(onPinA, LOW);
+  delay(1000);
+  digitalWrite(onPinA, HIGH);
+  Serial.println("Sockets on complete.");
+  // Send ON signal to PI
+}
+//Function to send a radio signal to turn sockets off
+void turnSocketsOff() {
+  // For RPi parsing
+  Serial.println("status : 0");
+  Serial.println("Turning sockets off: ");
+  // turn off 3 times
+  digitalWrite(offPinA, HIGH);
+  delay(1000);
+  digitalWrite(offPinA, LOW);
+  delay(1000);
+
+  digitalWrite(offPinA, HIGH);
+  delay(1000);
+  digitalWrite(offPinA, LOW);
+  delay(1000);
+
+  digitalWrite(offPinA, HIGH);
+  delay(1000);
+  digitalWrite(offPinA, LOW);
+
+  Serial.println("Sockets off complete. ");
+  // Send OFF signal to PI
+}