Since Uno and Mega has no Serial, replace Serial with Console at Bridge Sample IDE code

/*
  SD card datalogger
 This example shows how to log data from three analog sensors
 to an SD card mounted on the Arduino Yún using the Bridge library.
 The circuit:
 * analog sensors on analog pins 0, 1 and 2
 * SD card attached to SD card slot of the Arduino Yún
 Prepare your SD card creating an empty folder in the SD root
 named "arduino". This will ensure that the Yún will create a link
 to the SD to the "/mnt/sd" path.
 You can remove the SD card while the Linux and the
 sketch are running but be careful not to remove it while
 the system is writing to it.
 created  24 Nov 2024
 modified 9 Apr 2024
 by Tom Igoe
 adapted to the Yún Bridge library 20 Jun 2024
 by Federico Vanzati
 modified  21 Jun 2024
 by Tom Igoe
 This example code is in the public domain.
 http://www.arduino.cc/en/Tutorial/YunDatalogger
 To see the Console, pick your Yún's name and IP address in the Port menu
 then open the Port Monitor. You can also see it by opening a terminal window
 and typing
 ssh root@ yourYunsName.local 'telnet localhost 6571'
 then pressing enter. When prompted for the password, enter it.
 */
#include <FileIO.h>
void setup() {
  // Initialize the Bridge and the Serial
  Bridge.begin();
  //Serial.begin(9600);
  FileSystem.begin();
  Console.begin();
  while (!Console) {
    ; // wait for Console port to connect.
  }
  //while (!Serial); // wait for Serial port to connect.
  //Serial.println("Filesystem datalogger\n");
  Console.println("Filesystem datalogger\n");
}
void loop () {
  // make a string that start with a timestamp for assembling the data to log:
  String dataString;
  dataString += getTimeStamp();
  dataString += " = ";
  // read three sensors and append to the string:
  for (int analogPin = 0; analogPin < 3; analogPin++) {
    int sensor = analogRead(analogPin);
    dataString += String(sensor);
    if (analogPin < 2) {
      dataString += ",";  // separate the values with a comma
    }
  }
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  // The FileSystem card is mounted at the following "/mnt/FileSystema1"
  File dataFile = FileSystem.open("/mnt/sd/datalog.txt", FILE_APPEND);
  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    //Serial.println(dataString);
    Console.println(dataString);
  }
  // if the file isn't open, pop up an error:
  else {
    //Serial.println("error opening datalog.txt");
    Console.println("error opening datalog.txt");
  }
  delay(15000);
}
// This function return a string with the time stamp
String getTimeStamp() {
  String result;
  Process time;
  // date is a command line utility to get the date and the time
  // in different formats depending on the additional parameter
  time.begin("date");
  time.addParameter("+%D-%T");  // parameters: D for the complete date mm/dd/yy
  //             T for the time hh:mm:ss
  time.run();  // run the command
  // read the output of the command
  while (time.available() > 0) {
    char c = time.read();
    if (c != '\n')
      result += c;
  }
  return result;
}

Write comment (0 Comments)

Since Uno and Mega has no Serial, replace Serial with Console at Bridge Sample IDE code

/*
  Running process using Process class.
 This sketch demonstrate how to run linux processes
 using an Arduino Yún.
 created 5 Jun 2024
 by Cristian Maglie
 This example code is in the public domain.
 http://www.arduino.cc/en/Tutorial/Process
 To see the Console, pick your Yún's name and IP address in the Port menu
 then open the Port Monitor. You can also see it by opening a terminal window
 and typing
 ssh root@ yourYunsName.local 'telnet localhost 6571'
 then pressing enter. When prompted for the password, enter it.
 */
#include <Console.h>
#include <Process.h>
void setup() {
  // Initialize Bridge
  Bridge.begin();
  // Initialize Serial
  //Serial.begin(9600);
  // Wait until a Serial Monitor is connected.
  //while (!Serial);
  Console.begin();
  while (!Console) {
    ; // wait for Console port to connect.
  }
  // run various example processes
  runCurl();
  runCpuInfo();
}
void loop() {
  // Do nothing here.
}
void runCurl() {
  // Launch "curl" command and get Arduino ascii art logo from the network
  // curl is command line program for transferring data using different internet protocols
  Process p;		// Create a process and call it "p"
  p.begin("curl");	// Process that launch the "curl" command
  p.addParameter("-k");
  p.addParameter("https://www.arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl"
  p.run();		// Run the process and wait for its termination
  // Print arduino logo over the Serial
  // A process output can be read with the stream methods
  while (p.available() > 0) {
    char c = p.read();
    //Serial.print(c);
    Console.print(c);
  }
  // Ensure the last bit of data is sent.
  //Serial.flush();
  Console.flush();
}
void runCpuInfo() {
  // Launch "cat /proc/cpuinfo" command (shows info on Atheros CPU)
  // cat is a command line utility that shows the content of a file
  Process p;		// Create a process and call it "p"
  p.begin("cat");	// Process that launch the "cat" command
  p.addParameter("/proc/cpuinfo"); // Add the cpuifo file path as parameter to cut
  p.run();		// Run the process and wait for its termination
  // Print command output on the Serial.
  // A process output can be read with the stream methods
  while (p.available() > 0) {
    char c = p.read();
    //Serial.print(c);
    Console.print(c);
  }
  // Ensure the last bit of data is sent.
  //Serial.flush();
  Console.flush();
}

Write comment (0 Comments)

Arduino Mega/Uno IDE working sample code:

Bridge

ConsoleAsciiTable

ConsolePixel

ConsoleRead

ConsoleHttpClient

client.noCheckSSL(); 
client.get("https://www.arduino.cc/asciilogo.txt");

ConsoleProcess

p.addParameter("-k");
p.addParameter("https://www.arduino.cc/asciilogo.txt");

ConsoleDatalogger

ln -s /mnt/sda1 /mnt/sd

ConsoleFileWriteScript

ConsoleShellCommands

ConsoleTimeCheck

ConsoleWiFiStatus

Write comment (0 Comments)
curl -V
curl 7.29.0 (mips-openwrt-linux-gnu) libcurl/7.29.0 OpenSSL/1.0.1h zlib/1.2.7
Protocols: file ftp ftps http https imap imaps pop3 pop3s rtsp smtp smtps tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP

curl 7.29.0 (mips-openwrt-linux-gnu) has limit at string size we pass it and does not report error if over limit.

The work around:

curl -k  -X PATCH  -d @/mnt/sda1/test.base64 'https://shms.firebaseio.com/images/image.json' > /dev/null 2>&1

Put long string at file "/mnt/sda1/test.base64"

Hide standard and error outputs.

Write comment (0 Comments)