How to send hx711 data to remote database server using a nodemcu? - arduino

I want to create a digital scale and view it's readings live in my website. I am using a nodemcu for this purpose. I have created a small program that reads the data from a hx711 amp which is connected to 2 loadcells. Now I want to take that data and send it to a database server and then pull the data into my website. I have searched a lot and followed a lot of tutorials but cannot understand how to get the data from the loadcell to the database. Here is my code that can read the loadcells :
#include "HX711.h"
#define calibration_factor 895000 //random value, i can adjust it later
#define DOUT D1
#define CLK D2
HX711 scale(DOUT, CLK);
void setup(){
Serial.begin(115200);
Serial.println("Claibrate");
scale.set_scale(calibration_factor);
scale.tare();
Serial.println("OK");
}
void loop(){
Serial.print("Reading");
Serial.print(scale.get_units(), 3);
Serial.println("kg");
}
This is my first time doing a iot project so please help me somebody and also let me know if I missed out some vital info.

I'm not sure what the exact issue is here, or maybe you are just getting started, but here are a couple of suggestions:
if you want to store time series data, InfluxDB is nice and fast, simple and appropriate. So you would install InfluxDB ideally on your web-server host, or possibly on a PC or a Raspberry Pi somewhere on your network. Then send your readings from the NodeMCU with the InfluxDB client like this
you might like to use Redis which is extremely fast and lightweight. So you could run that on your web-server host, or some other PC or Raspberry Pi on your network and use a Redis client on NodeMCU to push the readings into a Redis LIST where your web-server could pick them up from. This is nice and easy because you can inject data into Redis and also read it straight from the command-line which is great for testing and debugging. Example here.
if you want to use some other database, you could use MQTT on your NodeMCU to send your readings to a broker, such as Mosquitto installed and running on your web-server host. You could then have a "bridge" that subscribes to the "weight" topic and when readings arrive, it could then push them into any database you like. Example here.

Related

Serial communication between esp32 and iRobot Scooba 450

I am looking to modify my Scooba 450 vacuum to make it remotely controlled.
So I searched and came across this and this.
After trying different ways, I ended up getting it to work in python, with a computer running at 57600 baud. So far, so good.
But for it to be remotely controlled, I wanted to use an ESP32, I tried a lot, but I can't communicate with the robot.
Normally, when it is charging, it returns information about its battery. So I put it on charge, and tried to read his data with the ESP32, but no information comes in.
I tried connecting it directly with a micro USB to micro USB cable, but without result.
I also of course checked that the cable is working, that data is currently being sent from the Scooba.
The program:
void setup() {
Serial.begin(57600);
}
void loop() {
while (Serial.available()){
Serial.print((char)Serial.read());
}
}
My goal would be to be able to control it from a site, but before that, I must succeed in communicating with the Scooba. I don't necessarily need to be connected to the computer to know if data is being received, because I can see if the LED on it is on.
Thanks

Arduino WiFi Shield works only for 2 second delays?

I am trying to send sensor data from an Arduino UNO to my server running on a local wifi network. My server is an HTTP server run on NodeJS.
I need the Arduino to send data to the server as fast as possible as fast as a request every 100~250ms. The code from the WiFiClientRepeating example sends data to the server properly every second or so. If I reduce the frequency to something lower or equal to 500ms, the server does not seem to receive anything.
Are there any limitations to how many requests there can be done in a set period of time?
EDIT: I am using the official Arduino WiFi Shield.

How to send data to cloud from arduino uno?

I have some sensors connected to my ardunio uno and get periodically data from that sensors now I wanted to send that data to cloud.
I dont have any idea about how should I connect my arduino to Internet using GSM. How should I solve this problem or any alternative is there.
Just get an appropriate shield (like this one) and follow the documents included with it. The linked shield includes some basic service plan as part of the purchase. Once connected, it's just like using any other TCP/IP application.

Send data from serial port to a local websever

I have a Temp sensor connected to my arduino uno sending its data to the serial monitor e.g
16c
How can I send the data from the serial monitor to a local webserver so that i could access the temp from a internet browser?
In the setup I use with my arduino I am using NodeJS SerialPort module to listen to signals of my arduino with a motion sensor. To serve the signal data to the web in real time, I use the socket.io module for NodeJS. You can find quite a lot about this on the internet, for example this tutorial which is somewhat close to what I use.
http://www.codeproject.com/Articles/389676/Arduino-and-the-Web-using-NodeJS-and-SerialPort

Arduino UNO + Enc28j60 + DHT11 +PHP & Mysql (LAN MODE)

I'm a arduino newbie, I would like to build an web project for my thesis.
I use arduino uno as microcontroller, DHT11 for temperature sensor and Enc28j60 for the ethernet shield.
The project is used to control LED and monitor the temperature and humidity through a website.
I want to set arduino as client.
I want to simulate this project in LAN mode.
I want to ask:
1. how to set arduino as client?
2. how to receive the temperature data from the arduino and store it to the database(mysql)?
3. how to control led via website?
I had tried arduino as server, and it is succeed.
But I confuse how to set it as client
thank you,
anyone can help me?
You could set up a web server on the computer, and have the Arduino make a GET or POST request to a script (e.g. PHP) on the server that saves values to the database. You could also get the server to return a value that indicates whether the LED should be on or off. More details are found in the Arduino help: http://arduino.cc/en/Reference/EthernetClient
To get the LED to respond quickly in this setup would require the Arduino to continuously poll the script however, which doesn't seem ideal. Why do you want the Arduino to be the client?
because I need to store the temperature data to the database. If I set arduino as a server. I dont know how to store the data to the database. I still dont understand about to control my lamp if i set the arduino as webclient

Resources