Hi! Not exactly sure which subforum is most appropriate for this question, but here I am..
I'm on a Nano 33 iot device, and when following a couple of examples, I noticed that when I use the "upload" button on the IDE, it will print:
Write 30124 bytes to flash (471 pages)
[==============================] 100% (471/471 pages)
done in 0.188 seconds
I've read that each device can only write to Flash for a particular amount of times (something like 10,000 or 100,000) - My question is simply: Does this Upload operation count as one of those times? If so, is there anything I can do (change in my code) so that it doesn't do this every time I do an upload? Current Code pasted below, thanks in advance!
//#include <HX711_ADC.h> // https://github.com/olkal/HX711_ADC
#include <Wire.h>
#include <HX711_ADC.h>
#include <WiFiNINA.h>
// Initiate LoadCell
HX711_ADC LoadCell(2, 3); // parameters: dt pin, sck pin<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>
//Initiate WifiClient
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;
int status = WL_IDLE_STATUS;
//ip address with http
WiFiClient client;
IPAddress server(192, 168, 0, 119);
int portNum = 8000;
// frequency? We can set other criteria
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds
long t;
float calibration_factor = 2.61; // device dependent
void setup() {
LoadCell.begin(); // start connection to HX711
LoadCell.start(2000); // load cells gets 2000ms of time to stabilize
LoadCell.setCalFactor(999.0); // calibration factor for load cell => strongly dependent on your individual setup
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Getting started!");
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
Serial.println("Please upgrade the firmware");
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
// you're connected now, so print out the status:
printWifiStatus();
}
void loop() {
const int serialPrintInterval = 10000; //increase value to slow down serial print activity
static boolean newDataReady = 0;
// check for new data/start next conversion:
if (LoadCell.update()) newDataReady = true;
// get smoothed value from the dataset:
if (newDataReady) {
if (millis() > t + serialPrintInterval) {
float i = LoadCell.getData();
Serial.print("Load_cell output val: ");
Serial.println(calibration_factor * i);
newDataReady = 0;
t = millis();
uploadScaleData(2);
}
}
// receive command from serial terminal, send 't' to initiate tare operation:
if (Serial.available() > 0) {
float i;
char inByte = Serial.read();
if (inByte == 't') LoadCell.tareNoDelay();
}
// check if last tare operation is complete:
if (LoadCell.getTareStatus() == true) {
Serial.println("Tare complete");
}
}
// this method makes a HTTP connection to the server:
void uploadScaleData(float scaleValue) {
// close any connection before send a new request.
// This will free the socket on the Nina module
client.stop();
// Construct POST data
String PostData="udid=xxxxxxxxxxx&record_value=25.32";
// PostData = PostData+"\"record_value\": 25.32}";
Serial.println(PostData);
// if there's a successful connection:
if (client.connect(server, portNum)) {
Serial.println("connecting...");
// send the HTTP PUT request:
client.println("POST /devices/upload-scale-reading/ HTTP/1.1");
client.println("User-Agent: ArduinoWiFi/1.1");
client.println("Content-Type: application/x-www-form-urlencoded;");
client.print("Content-Length: ");
client.println(PostData.length());
client.println();
client.println(PostData);
client.println("Connection: close");
client.println();
// note the time that the connection was made:
lastConnectionTime = millis();
} else {
// if you couldn't make a connection:
Serial.println("connection failed");
}
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your board's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}