Project using Arduino

Use bolt.serialRead(10) not ('10')

I tried that too, but not working for me.

But according to @rahul.singh1, there is no difference between both.
P.S: See previous reply by @rahul.singh1

I see you have used data1, response1 in the code, can you avoid using numbers when assigning to variables? Try data_a and response_a maybe and try?

Did the changes. Getting null values

Yes, that’s because the serial monitor is empty as of now. serialRead(10) reads 10 characters of incoming datas.

This means, the bolt has to first use serialWrite to write to the monitor. Only then you will find a value.

To proceed to the programming part-
First, write the Arduino code for NANO to READ the values with the sensor. Use serialWrite to push the data to the monitor.
Then, write a python program to read the serial monitor using serialRead(‘10’). Bolt has mentioned using ‘10’ because the ASCII value of 10 is ‘\n’ (newline)

Still getting null values.

Can you please check my arduino code once?

Have you run written anything on the serial monitor that you are trying to read using serialRead?

If there is nothing written on it, you will get null value only.

Hello @akshayan.sinha,
I don’t think serialWrite is required because the sensor values are already being pushed to the Bolt cloud

Sensor values are either digital or analog data in the cloud. serialWrite HAS to be used to written to the serial monitor. Or, you will be trying to read an empty book using serialRead.

You have to push the data to the cloud using serialWrite first.

For reference on how to work with Arduino and bolt, go through the readme.md here VERY CAREFULLY - https://github.com/Inventrom/boltiot-arduino-helper

This is confusing!!

Please provide me a simple Arduino code to send one or more values (integer type).
Lets see if this work.

So, if I do not use serialWrite,I won’t be able to plot graphs in Bolt cloud using Javascript, right?

Plotting graphs with arduino data might be a bit difficult for me to help you with.

But i can show you two samples you can practically try and get the sensor value for now.

I suggest you to do a basic serial communication project on tinkercad. By using 2 arduinos.

If you want the Arduino to send analog values of all analog input pins when the Bolt sends the command “getAnalogData” via the serial interface

 String getAnalogData(String *data){
    	String retval="";
    	retval=retval+analogRead(A0)+",";
    	retval=retval+analogRead(A1)+",";
    	retval=retval+analogRead(A2)+",";
    	retval=retval+analogRead(A3)+",";
    	retval=retval+analogRead(A4)+",";
    	retval=retval+analogRead(A5);
    	return retval;
    }

Then call it in void loop()
boltiot.setCommandString("GetAnalogData",getAnalogData);

How it usually looks without defining the inputs and pins -

#include <BoltIoT-Arduino-Helper.h>
String getAnalogData(String *data){
    	String retval="";
    	retval=retval+analogRead(A0)+",";
    	retval=retval+analogRead(A1)+",";
    	retval=retval+analogRead(A2)+",";
    	retval=retval+analogRead(A3)+",";
    	retval=retval+analogRead(A4)+",";
    	retval=retval+analogRead(A5);
    	return retval;
    }
void setup() {
  boltiot.begin(Serial); //Initialize the Bolt interface over serial UART. Serial could be replaced with Serial0 or Serial1 on Arduino Mega boards.
		   //In this example, the TX pin of Bolt is connected to the RX pin of Arduino Serial Port
		   //and the TX pin of Bolt is connected to the TX pin of Arduino Serial Port
  pinMode(2,INPUT); //Set pin 2 as the input. We will use send this pin's state as the data to the Bolt cloud
}

void loop() {
  boltiot.handleCommand(); //Send data to the Bolt cloud, when the Bolt polls the Arduino for data.
/*This function needs to be called regularly. Calling the processPushDataCommand function once every second is required*/
boltiot.setCommandString("GetAnalogData",getAnalogData)
}

After this make a python/JS/HTML to perform the tasks with this URL-

https://cloud.boltiot.com/remote/44b2de6b-7e68-40e7-a27f-814b58afe008/serialWR?data=A,B,C&till=10&deviceName=BOLT8795377

Where A,B,C will trigger the python/JS/HTML to make the arduino perform the task.