Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
1,887 Views

MQTT library not working on bootup in Galileo Gen 2.0

Jump to solution

I am trying to run Pubsub client on Galileo gen 2.0. the code runs fine but does not start when I boot up the board. I need to upload it every time through the IDE in order to execute the code.

The blinky code runs fine on boot up.

The firmware version of my board is

root@galileo:~# cat /etc/version

201606081532

The MQTT client library can be found here: https://github.com/knolleary/pubsubclient https://github.com/knolleary/pubsubclient

0 Kudos
1 Solution
idata
Community Manager
88 Views

Hi Parth,

 

 

Apparently, it takes ~120 seconds for the WiFI to be ready during boot, but it takes ~90 seconds for the Arduino sketch to be ready during boot. This creates a conflict because the Arduino sketch is configuring a network connection that doesn't exist yet. We have tested this with the mqtt_basic example from the original source you have provided https://github.com/knolleary/pubsubclient https://github.com/knolleary/pubsubclient, adding a ~20 second delay as part of the sketch gives enough time to the WiFI connection to be ready. This seems to have solved the issue, please try adding a delay on the sketch as the first instruction of the setup function and see if it solves the issue.

 

 

Regards,

 

-Pablo

View solution in original post

19 Replies
idata
Community Manager
88 Views

Hi Loop,

 

 

Thank you for contacting us. Could you please share the code and the service you're using so we can test it?

 

Also, the configuration you're using or anything specific around the board that should be set while testing.

 

We'll be waiting for your reply.

 

 

Regards,
idata
Community Manager
88 Views

Sure,

Can you share me an email where I can send you the code.

Regards,

Parth Desai

idata
Community Manager
88 Views

I did email you the code for review and test.

Regards,

Parth Desai

idata
Community Manager
88 Views

Hi Loop,

 

 

Thank you, we have received your email.

 

In the future, when you need to share some code, you can open an email ticket following this link https://supporttickets.intel.com/?lang=en-US https://supporttickets.intel.com/?lang=en-US. It will be easier for us to help you and for you to share your private code.

 

 

Regards
idata
Community Manager
88 Views

Hi Loop,

 

 

Besides the Blink example, have you been able to run some other sketch at boot? I've running some tests with some other examples like ReadAnalogVoltage and while the LED on the board kept blinking, the output on the Serial Monitor indicated that the ReadAnalogVoltage was indeed running (even after boot).

 

Did you make sure that your sketch galileo_loopmq is not running at all?

 

 

Regards,

 

-Pablo
idata
Community Manager
88 Views

Hello Pablo,

I tried the analog read value and it also works fine after boot up. I tried to debug mu code too and found that it does start after boot up, but does not connects to the internet. If you will try to run my code and debug it on serial you will get an error of tryint to connect to the internet.

The same code does work fine, if I compile it and upload on the board. Can you tell me why I am facing this issue.

Thanks,

Parth Desai

idata
Community Manager
88 Views

Hi Parth,

 

 

Yes, that's actually the behavior I'm getting with other sketches. I also run your source code and the sketch seems to be running fine at boot. Let me run some more tests with your sketch and with other Network samples from the IDE to see how they behave. We will contact you soon.

 

 

Regards,
idata
Community Manager
88 Views

Hi Parth,

 

 

We would like to share some updates with you. We've confirmed that with other sample code from the IDE, like the PachubeClient sample, we are having the same issue. It seems to work fine when uploaded it from the IDE, but fails to connect when running at boot. We're still investigating and will provide updates soon.

 

 

Regards,

 

-Pablo
idata
Community Manager
89 Views

Hi Parth,

 

 

Apparently, it takes ~120 seconds for the WiFI to be ready during boot, but it takes ~90 seconds for the Arduino sketch to be ready during boot. This creates a conflict because the Arduino sketch is configuring a network connection that doesn't exist yet. We have tested this with the mqtt_basic example from the original source you have provided https://github.com/knolleary/pubsubclient https://github.com/knolleary/pubsubclient, adding a ~20 second delay as part of the sketch gives enough time to the WiFI connection to be ready. This seems to have solved the issue, please try adding a delay on the sketch as the first instruction of the setup function and see if it solves the issue.

 

 

Regards,

 

-Pablo

View solution in original post

idata
Community Manager
88 Views

Hey Pablo,

Thanks for getting back to me.

I do not have a Wi-Fi module and so I am using the Ethernet module to connect to the internet.

I tried to have a delay of ~20 to ~50 seconds after

```

Ethernet.begin(mac)

```

in the void setup() function.

I still see the same problem and my sketch does not work on boot-up.

Can you please try to debug my code and see if it works.

Regards,

Parth Desai

idata
Community Manager
88 Views

Hi Parth,

 

 

Thank you for the quick reply.

 

I would like to know if you have access to a Galileo with a WiFi module that you can use to test our configuration. We will try to do the same test with an Ethernet connection but we would also like you to run some tests with a different configuration. Maybe you can borrow a WiFi PCIe card from a friend to use on your Galileo.

 

 

Regards,

 

-Pablo
idata
Community Manager
88 Views

Hi Pablo,

I do not have a Intel® Centrino® Advanced-N 6205 or Intel® Centrino® Wireless-N 135 that works for Galileo gen 2. If I get hold of one, I will try and post the results. Until then I will wait for the Ethernet testing from your side.

Thanks,

Parth

idata
Community Manager
88 Views

Hey Pablo,

I just ordered a new Wi-Fi module and will receive it in a week, will check the same then.

Thanks,

Parth Desai

idata
Community Manager
88 Views

Hi Parth,

 

 

We will run some tests on our own and will let you know what results we get. Please keep us posted with your tests too.

 

 

Regards,

 

-Pablo
idata
Community Manager
88 Views

Hey Pablo,

I just received the Intel Centrino Advanced N 6205, I installed it and tried to run my sketch with the configurations given by you. I still face the same problem on boot up.

I varied the delay from ~20 secs to ~2000 secs after Ethernet.begin(mac); but still it does not connect to the internet, however the code runs fine when loaded to the device.

Regards,

Parth Desai

idata
Community Manager
88 Views

Hi Parth,

 

 

I am now doing my tests with Ethernet. I will provide some updates of my results tomorrow, and will check what is causing your issue even with WiFi antenna.

 

 

Regards,

 

Pablo
idata
Community Manager
88 Views

Hi Parth,

 

 

I have some updates on this case, thank you very much for your patience.

 

I wasn't able to get the sketch working using an Ethernet Connection, no matter how much time I added to the delay, it never connected. So, I can say I was able to replicate your issue with the sketch running at boot.

 

However, this is not the case with the WiFi card, which is working as expected. Where are you adding the delay on your code? I'm adding a 30s delay right after the void setup() function, as the first command.

 

 

Regards,

 

Pablo M.
idata
Community Manager
88 Views

HI Pablo,

I used to put the delay after Ethernet.begin(mac); but I tried to put the delay after void setup();and the sketch works fine on boot-up.

So are you going to try further tests on how to get the sketch up and running using Ethernet or I should use Wi-Fi only and recommend same to the users?

Thanks for the help.

Regards,

Parth Desai

idata
Community Manager
88 Views

Hi Parth,

 

 

I wasn't able to make the example work with Ethernet at all, not even when uploading the code with the Arduino IDE and having the Edison powered on. So there might be an issue with my Ethernet configuration.

 

You can try adding the same delay to the sketch but using an Ethernet connection, if you get it to work you can choose any of the configurations, but from my experience I would stick to the WiFi card.

 

 

Regards,

 

Pablo M.

 

Reply