Electronic – arduino – reprogram the Arduino via a wifi shield

arduinowifi

My Arduino is hooked up to some lights over my aquarium and I can control them from a web browser on my LAN. I wonder if I can modify the program on the Arduino without having to plug it into a machine via USB which would be a little inconvenient. There must be some way I can take advantage of the wifi connection.

I have used Pololu's wixel shield to send programs wirelessly (it just acts as a serial port radio) but that's a different technology than my WiFi shield.

Does anybody know of a way I can do this via WiFi? Maybe if I upload new code to the flash memory in the WiFi shield, it could then bootload from the flash memory? I'm not sure how to do that or if its even possible.

Perhaps a completely different approach would be simpler?

Best Answer

It is possible, in theory, but not trivial in practice. The piece of code responsible for loading your new sketch to the Arduino is called the bootloader. All the popular versions of bootloaders I know of are serial/USB based. In order to load a sketch over the WiFi shield, the bootloader would have to be rewritten to communicate with the WiFi shield instead of serial. This would take some work, but not impossible in practice.

Note that you'll have to do this regardless of whether you are storing the sketch on the WiFi shield (which I think would be difficult: I am not sure if this is possible at all) or uploading the sketch directly to your Arduino: the bootloader will need to communicate with the shield to read the sketch data.


There is a way to reprogram your Arduino wirelessly easily, and that's Bluetooth. You will need to get a Bluetooth module (I don't know if a Bluetooth shield will work) and connect it to hardware serial ports. The bootloader that is on your Arduino can already talk serial, so that problem is solved. You will have to (potentially) solve two other problems though:

  • The lowest-cost bluetooth modules you find on Ebay are 3.3V. This means you will have to supply them with 3.3V power, and the send line from your Arduino will need to be voltage-shifted from 5V to 3.3V. You can solve the first (power) sub-problem by purchasing a Bluetooth module that is made for 5V communication, or if your Arduino has 3V3 power using that to power the Bluetooth module. A 5V-ready module also solves the second problem; alternatively, you can voltage-shift the 5V output from your Arduino using any of the techniques describe in this question.
  • In order to program your Arduino automatically, the Arduino needs to be reset right before the sketch is uploaded: when Arduino runs normally the bootloader is not active. Resetting the Arduino activates the bootloader, enabling uploads of new sketches. on the Arduino USB cleverly uses the DTR line to reset the device. Most Bluetooth serial modules, however, only provide TS/RX out, so you will probably have to reset the Arduino manually to upload a sketch, unless you can find some signal output on the Bluetooth module that you can marshall to connect to a reset circuit.