Showing posts with label internetofthings. Show all posts
Showing posts with label internetofthings. Show all posts

Wednesday, 22 July 2015

My adventure with ESP8266 (2/2): flash it!

Introduction 
The first part is here and it is about:
  • hardware
  • software
  • firmwares
  • nodemcu
It contains important information to understand this part.

Wirings
This table show how to connect the hardware together:


Pay attention to GPIO0, you need it connected only for flashing.

Flashing!
It's time to flash the device with a new firmware using esptool.
I decided to flash a nodemcu firmware.
Connect the GPIO0 to GND and than power on the device.
On my installation on OSX I did this command to flash the device:

python esptool.py -p /dev/tty.usbserial write_flash 0x00000 nodemcu_21072015.bin

If everything is ok, you should see this message:


Power off the esp8266 than remove the GPIO0 connection and than power on the chip again.

Talk with ESP8266
Now, it's time to talk with the chip.
I use kermit with this .kermrc configuration:

set carrier-watch off
set line /dev/tty.usbserial
set speed 9600

than you can press "c" to connect and typing print ("hello"); you should see the device responding hello back.
Now you can test some commands.

If you have downloaded the luatool, you can write your programs in a text file with lua extension and upload on the board with

python luatool.py --port /dev/tty.usbserial --src main.lua --dest main.lua --baud 9600

Lua files
Now, you can connect to the esp8266 and type dofile("main.lua"); to run the program.

If the file you are loading on the device, it is called init.lua the esp8266 at every boot will load it: pay attention, a bad init script can block the device forever... The only solution in this case is a re-flash of the device.

If you have any question, feel free to ask in the comments section.
If you like the article please share it! :)

my wirings :)



Tuesday, 21 July 2015

My adventure with ESP8266 (1/2)

Introduction
This article will explain all the steps I did to succesfully use the ESP8266 chip.
The ESP8266 is a an incredible low cost chip (< 5$!) to enable wifi communication for your project.
It is capable of:
  • create a wifi network: a wifi hotspot
  • connect to existing wifi hotspot
  • programmable digital pins: with I2C or SPI support!
I think this is ideal for many IOT project, at least in a prototype stage.
The chip is pretty new but thanks to its "open" nature and its cost, there are already some alternative firmware available.
This guide is tested for OSX Yosemite, but you can find similar tools also for Linux and Windows.
You can find different variants of ESP8266, but I think this tutorial will work equally with all the versions.

My version is the "04":
isn't it too cute ??? :D

My Hardware
  • CH340G USB to Serial (TTL) converter
  • ESP8266: I have the version 04
  • A stable 3.3v power with enough ampere to power the chip: I used a step down converter from 5V to 3.3V, the LM2596 calibrated with a multimeter and connected to a 5V/2A phone charger
  • a computer
Software
  • driver for CH340G here
  • kermit-c or any serial terminal software (minicom for example). For OSX
  • a firmware to flash: read below
  • esptool.py here
  • luatool here: valid only with nodemcu firwmare
Firmwares
The default firmware of the chip can be outdated.
This firmware exchange data with AT command on serial line.
A list of commands is here, but commands can change in every firmware.
This firmware is good if you need to connect the ESP8266 to other components (for example an arduino).
My esp8266 comes with a firmware not capable of talk with AT commands in any f*****g way, it started as an hotspot (see image) but I was not able to talk with at any serial speed.

BTW, the hotspot check is a good way to control if the ESP8266 is correctly connected


I flashed a new updated version of the official firmware.
The default firmware is splitted in 4 .bin files: I have to power off and than power on the chip after each flash.
I than tested the AT command with kermit-c, pressing CTRL+J in the terminal after every typed command.
As far as I know, It is possible to create custom programs using the EspressIf SDK and C++.

NodeMCU
I decided to test another firmware and the choice was the nodemcu firmware.
This firmware lets you write scripts in LUA language; it's a new language for me, but the syntax is pretty simple.
The advantage here are:
  • upload scripts, without reflashing the firmware
  • the availability of a powerful and simple API with a good documentation

[the second part is available here]

Monday, 14 October 2013

My First Impressions On The Arduino Yun

These are great years for geek: hardware is cheaper and new gadget come out everyday
It's our time!
Our creativity is screaming inside us, due to the incredible number of things that everyday comes out.
Some days ago I bought an Arduino Board Yun (all the specs here).

I mainly bought it just to support Arduino: because it's an italian project and I was curious to see if the new Yun have the same potential of Arduino Uno.

Anyway reading the specs, these are the things that I like most on this board:

  • The Arduino part of Yun is an Arduino Leonardo's like (mouse and keyboard feature!)
  • ethernet,wifi,sdcard support: no more expensive shell to add (Note: if you can reach internet you can use NTP, so you don't need an RTC)
  • a real processor with Linux: and all the possibilities offered by linux software. The distro is Linino, based on the famous OpenWrt!
  • linux + usb: means attach webcam, pendrive, other usb devices.
  • POE support(from the doc: "The Yún is also compatible with PoE power supply but in order to use this feature you need to mount a PoE module on the board or buy a preassembled one."
  • Wifi capabilities means: no bother with bluetooth, zigbee, android adk... you can write app on mobile that talk with Yun just with http/html/js (for example).
  • Wifi support accesspoint mode: this means you can connect things with wifi using Yun as the hotspot
  • Can be remote programmed: do you need to upgrade the software on the arduino connected in another room? Now you can thanks to wireless
  • Same dimension of the current Arduino Uno.
  
Arduino Uno (left) & Yun (right)

  • Temboo: do you need to use dropbox, flickr, twitter, facebook, google calendar, google docs or other online services with your Yun? Temboo is a framework that let you work with those services easily, standardizing the way you access these API... and it works with your Yun of course!

I don't think Yun is here to beat raspberry pi (maybe only in few project) but to replace existing project with Arduino uno/leonardo with a new powerful version able to: easy connect to internet, communicate with "things", remove expensive shields, improve experience and help you to fast prototype IOT objects.
For now, it seems that the standard Linino image shipped with yun is limited..but it's Opensource Baby... and so..the next step is this: github/repo.
See you soon with new info about Yun!