Foreword

This is experimental and not exactly for beginners, something may be wrong. Proceed with caution or you can break something!

A (not so) brief introduction.

I’ve been working on a new robot called RoDI for a summer course at my Alma mater. RoDI is a low cost wireless robot to teach robotics and programming I started developing last year (reminder to self: I still need to post about it), but it wasn’t until a month ago that I started to work on it more often.

The first version used a HC-06 Bluetooth module to communicate with the computer. I wanted to to use WiFi, but the cost of the WiFi modules was a problem, since the idea was that the entire robot would cost less than 30 USD.

Then, I read about the ESP8266 WiFi modules on Hackaday, and started working on a new version of RoDI, this time with WiFi :D. I wanted to be able to flash the atmega328 inside the robot via WiFi because the robot doesn’t have a USB to Serial converter.

I found (again on HaD) a blog that showed how to flash an Arduino via WiFi with these modules, but it uses the ESP8266 to connect to a router, as we’re planning to have a few of this robots, and the student will take these robot and it doesn’t have another way of flashing the chip unless they have a programmer, so this method wouldn’t work for the robots. One thing that I learn from the blog was that I was going to need to use the transparent mode and, of course, use the module as an AP. Bad news, transparent mode is not available when using the module in server mode with the at_v0.20_on_SDKv0.9.3 version of the at command example. Time for hacking it!

After reading through the source code for the AT commands firmware I was able to enable transparent mode when using the module as a server. One security issue for this is that it supports up to 5 connections, so is not completely secure. I asked and got this response but wasn’t able to find that method (or variable?). I found another method that consist on configuring the AP using the wifi_softap_get_config method from the SDK, which lets us set the max_connection parameter. Yet another option is to add a password to the AP. But… we plan to use it only for robots in a summer course, so the security isn’t really important for now. 😉

Let’s get to work…

Connecting all together

CAUTION: This assumes you’re using a 3.3V Arduino. I’m not responsible for any broken Arduino or ESP8266 modules.

Simplified connection diagram

Mods

We need to do some modifications to the ESP8266 AT firmware, arduino bootloader and the programmer software in order to successfully use it to program the Arduino, here are the mods:

I’ve added a new AT command called AT+RODI that set the module as an AP, starts the transparent server mode, configures the GPIO used for resetting the Arduino and starts a TCP server on port 1234. You can find the code on my esp8266_at fork on my github account. For a guide on how to install the toolchain, you can follow this guide. And for a script to build and program the ESP8266 you can take a look here. Note: to enter AT mode, send +++.

Then I’ve modified Arduino’s bootloader to send the ” character so it can be picked up by the programmer script. You can find the modified code here. (I think this is not entirely necessary but made things easier for me)Update: After some testing, I found out that there is not necessary to modify the bootloader, you can omit this step.

Lastly I’ve modified the python script programmer from sistemasorp to add support so it can work as a client connecting to the ESP8266 for programming. You can find the modified code here.

So, the steps needed are:

Build modified AT firmware for the ESP8266.

Program the new firmware onto the module.

Compile the modified bootloader and flash it to the atmega using a programmer. I use the USBasp or the buspirate

Connect via WiFi to the ESP8266’s AP. You should get an IP address like 192.168.4.100

I am working in a robotics project where keeping the cost low is crucial. So in order to reduce costs and make the robot easy to program and connect to various types of sensors easily, I choose to use an ATmega328p so I can use the Arduino enviroment but using the internal 8MHz clock.

Here are the steps I made to program the bootloader into the ATmega328p chip using the all-mighty Bus Pirate froam Dangerous Prototypes:

Connect the BP to the microcontroller according to this (add link) table.

in a terminal check the connection between the BP and the microcontroller using

After a few problems with the local post office, I finally received my free PCBs from Dangerous Prototypes. This time I received two MMA7455L accelerometer breakout boards. It has a Freescale’s MMA7455L accelerometer in a LGA-14 package. It was not difficult to solder using the right method (a lot of patience and flux).

After the assembly, I tested both boards using the Bus Pirate and this tutorial.

Microchip has announced that it will release new cross-platform MPLAB XC C compilers by the end of March. They come in 3 versions depending on PIC family: XC8 is for 8bit, XC16 for 16bit, and XC32 for 32bit microcontrollers.

Microchip is releasing MPLAB XC C compilers in the upcoming weeks. There will be three, one for each of the major Microchip logic architectures: MPLAB XC8, MPLAB XC16 and MPLAB XC32. By the end of March, we should have all three versions available. In the same open-platform spirit as MPLAB X IDE, MPLAB XC C Compilers will run on Windows, MAC and Linux. XC compilers will come with a new license manager to make installation and license management simple across platforms. Users will be able to install the compiler on any platform of choice.

I really like using GNU/Linux, especially Debian distributions (not Debian-based, just Debian). I was doing just fine until I bought a HP Pavilion dv7-4285dx laptop a few moths ago. It has a Intel Core i5 460 CPU, 6 GB of RAM and 640 GB HDD, another interesting feature is the switchable graphics system, that means, it has an integrated Intel GPU for low power / low performance and a discrete ATI Mobility Radeon HD6370 GPU for high power/ high performance. It’s a nice feature but the problem is I never use the discrete GPU, but in a fresh installed Debian, both cards are turned on, generating a lot of heat and consuming/wasting a lot of power and therefore battery. In Virus Windows you can select which GPU to use with the ATI configuration utility.

I googled for solutions and many people could disable one of the GPUs using a module called vgaswitcheroo, which allows to select which GPU to use as well as turn the unused GPU off. I did everything the tutotials said but I couldn’t get it to work, for some odd reason whenever I tried to turn the discrete GPU off the OS gave some kind of weird errors and warnings.

So I started looking for another solution, and googling again I found another method to disable the discrete GPU using the acpi_call module, which I’ll describe here.

First you need to install the acpi_call module. I did it using this method, which I copy here.