Recent Posts

Pages: [1] 2 3 ... 10
Programming Questions / Re: String vs string vs char +...
Last post by xl97 - Today at 06:15 am
*not sure if I should make a new thread or not?


ok.. so I have something 'close' (I think).. LOL..

The problem is when I try to use the 'sub-parsing' function called in the 'while loop'.

If I comment out the parseAction() call in the while() loop... it executes, and delivers what I expect in the serial monitor.

*but that just a simple break down of sections by comma delimited character..  (havent stored them anywhere where they can be passed around and further parsed/broken down..etc).

if I un-comment that line.. and let it call the parseAction() function..

it executes ONE time perfectly.... then nothing else.

I get a DEBUG line in the (after the) WHILE loop saying that parsing of the comma delimited cunks is complete.. (when really only the FIRST one was parsed and attempted to be passed to the parseAction() function.)

Here is my code..

* paste this into the serial monitor:
<b=1:1,b=2:1,m=6:200>  and comment/un-comment line 72 for the parseAction(actionPacket); behavior results.

Code: [Select]
#define SOP '<'
#define EOP '>'
bool hasStarted = false;
bool hasEnded = false;

char incomingSerialData[100];
byte index;

char *actionPacket;
byte packetCounter;

int positionValue = 0;
int amountValue = 0;

void setup() {
  //serial monitor output

//example recipie format  (paste into serial monitor for output example)
//<b=1:1,b=2:1,m=6:200> = bottle#1/1 shot, bottle#2/1 shot, mixer#6/200ms

void loop(){
  // Read all serial data available, as fast as possible
  while(Serial.available() > 0){
    char incomingCharacter =;
    if(incomingCharacter == SOP){
      index = 0;
      incomingSerialData[index] = '\0';
      hasStarted = true;
      hasEnded = false;
    }else if (incomingCharacter == EOP){
      hasEnded = true;
      if (index < 100) {
        incomingSerialData[index] = incomingCharacter;
        incomingSerialData[index] = '\0';

 // Packet data done...parse/evaluate data
  if(hasStarted && hasEnded){
    Serial.print("TOTAL COMMAND PACKET (CP) CHECK: ");

    //packet counter reset
    packetCounter = 0;

    //get first delimited packets from command string
    actionPacket = strtok(incomingSerialData, ","); //split action packets from command string

    //keep parsing these delimited packets from the command string until there are none left to parse
    while(actionPacket != NULL){
      Serial.print("PARSED ACTION PACKET (AP) ");
      Serial.print(": ");
      //send off to parse function/loop for processing     
      //parseAction(actionPacket); //problem stems from here!!!!

      //update parsing params to next comma delimited chunk/action packet
      //only works if we dont call the 'sub parsing function' and pass in the pointer/value a a param
      actionPacket = strtok(NULL, ",");

    //parsing complete
    // Reset for the next packet
    hasStarted = false;
    hasEnded = false;
    index = 0;
    incomingSerialData[index] = '\0';


Project Guidance / Re: Flood Monitoring Device
Last post by larryd - Today at 06:12 am
"And also if it is okay too put the instructions on how to build it..."

We help you with questions you have, we don't do the work for you.

There is a Gigs and Colaboration section where you can ask people to do work for you.

Negative time makes no sense. How can you know that the input is going to start 5 seconds in the future?

Instead of turning the LED on and starting the timer when the PIR is HIGH, detect the change in the PIR. That means you should record what it was on the previous loop and compare against that.
Project Guidance / Re: Use multiple arduino's and...
Last post by Wawa - Today at 06:05 am
Might be able to do all of that with a single ESP8266 based board, depending what the "other sensors" are.

Google something like "ESP8266 RFID Arduino" (images).
Project Guidance / Re: Help with my code
Last post by MorganS - Today at 06:02 am
The code you have seems suitable for a momentary button.

What kind of "switch" do you have?
Portugues / Re: SIM800L não responde
Last post by Diego1270 - Today at 05:58 am
Estava com o mesmo problema na verdade ainda estou, mas gostaria de compartilhar uma possível causa para o seu problema. Possivelmente seu módulo veio configurado com a velocidade serial de 115200 onde você terá que fazer as mudanças tanto no código sketch quanto no monitor serial para só então realizar a mudança na configuração do módulo, pelo sketch de TESTE_GSM com comandos AT. Pelo menos no meu caso foi assim, agora o problema é que mesmo mudando a configuração do módulo pelo código AT+IPR=9600 ou qualquer outra velocidade desejada, sempre que inicializa-lo irá voltar para os 115200.... Logo acredito que seu sketch deverá conter esse código para configuração antes da inicialização do sketch. Só não descobri COMO?
Project Guidance / Re: Flood Monitoring Device
Last post by MorganS - Today at 05:58 am
What kind of flooding?

River flood?

Basement or bathroom floods?

Lawnmower engine starting problems?
Project Guidance / Re: Connecting 1 Arduino to 2 ...
Last post by MorganS - Today at 05:55 am
An Arduino Due has two USB ports. It can do this.

It is not a good idea to plug two different computers in at the same time. Their grounds may be different and there may be a lot of current flowing in the ground wire of the USB cable as a result. If you can run the laptop on its battery while the two are connected like this it will be much safer.
Project Guidance / Re: Flood Monitoring Device
Last post by goodSamaritan - Today at 05:53 am
You might consider the NODE-MCU. It is very cheap, and has built-in Wifi, which might be useful so you can monitor it remotely and keep your feet dry.
As long as the wifi routers and other infrastructure stay dry ;) but I guess that's a problem whichever way the OP does it*. Or sms is an option too.

It's dead simple to send stuff from a nodemcu to mqtt providers like adafruit. Attached (just as an example) is the adafruit dashboard showing pressure and temperature at my place: could just as easily be data from float switches etc. (Not sure if one can incorporate data from more that one nodemcu on the same dashboard, never tried that, seeing as I have only one node.)

*I wonder if the project is for real life deployment, where robustness will be important, or if it's a university lab proof-of-concept type of thing?

Project Guidance / Re: Sending multiple sets of i...
Last post by MorganS - Today at 05:50 am
You can't just make up your own functions. The compiler is telling you that there is no function to write 2 things like that.

If you want to write 2 things then use two writes. Write the first one, followed by the second.

There is a certain difficulty on the receiving side: how do you know the next byte is part of the first number or the second? There must be some kind of synchronization to tell the reader which one is which.

Read Serial Input Basics
Pages: [1] 2 3 ... 10