Categoria: IoT (Internet o Things)

Alexa + ESP8266 + OpenDevice

With Amazon Echo you can control your devices through voice commands. In this tutorial we will use an ESP8266, making Alexa recognize it with a compatible device, and with no configuration (incredible no?!?!).

Selection_368

For this we will use the OpenDevice library and enable the option to emulate a protocol compatible with Alexa.

The additional advantage to other similar tutorials is that we have all the benefits of OpenDevice, can connect via MQTT or receive commands via TCP

Setup:

Download and Install library: https://github.com/OpenDevice/opendevice-lib-arduino
You can all install using Arduino Library Manager.

Config:

Edit: OpenDevice/src/config.h
And uncomment  the line: #define ENABLE_ALEXA_PROTOCOL 1

Import this Sample (provided in library):
https://github.com/OpenDevice/opendevice-lib-arduino/tree/master/examples/Alexa4OpenDevice

Configure Wifi SSID and PASSWORD
NOTE: ODEV_API_KEY, is optional, only if you need integrate with OpenDevice Server

Upload and you must see in terminal:

Selection_369

Now Speak: Alexa, discover the devices
In the end, she should say that she found two devices.
Now you can talk: Alexa, turn ON the TV

This approach exposes some security issues (even disabling discovery). In a next step I will implement an Alexa Skill, which integrates with OpenDevice on the cloud (https), if you are interested, please contact me.

Anúncios

Que tal Hackear seu carro e plugá-lo na nuvem ?! (TDC/2017 SP)

Segue aqui os slides e vídeos da palestra.

Resumo:

Nessa palestra irei apresentar como você poderá acessar o computador de bordo do seu carro e coletar informações em tempo real, realizar detecção de falhas, e como enviar esses dados para nuvem para realizar análises. Você irá se surpreender em quais carros é possível fazer isso !!

Vídeo de demonstração do APP

 

Vídeo de demonstração do APP e Hacking do sensor de estacionamento.

 

Fontes:

Demo App (Andoird): https://github.com/OpenDevice/opendevice-examples/tree/master/IoTCar

Firmware (arduino) : https://github.com/OpenDevice/opendevice-examples/tree/master/IoTCar/firmware

OBD2 protocoll extension: https://github.com/OpenDevice/opendevice-extensions/tree/master/obd-connection

Backup and Flash SPI Memory using Arduino

After a wrong upgrade firmware of a TP-Link router, the only alternative was to write the flash memory directly.

The strategy I used was: Update only the u-boot sector, which is responsible for loading the kernel, and then updating using tftp [link].

It is possible to write all the firmware, however I preferred this method because it is faster. Writing the whole flash (ex: 8mb) can take about 10min.

I’ve developed a sketch for this purpose, and it can be downloaded from the link:
https://github.com/ricardojlrufino/SerialFlashSPI

The entire wiring diagram and details is also on the link above.

Notes

Currently (04-2017), it is only compatible with Winbond memories, but can be adapted for other libraries

I used the Arduino DUE because it is 3.3v. If you are using another arduino, you need to create a voltage divider.

The u-boot has 128 kb, which corresponds to the “512 pages” of “256 bytes”. You should adjust the base file size to the multiples of 256. This can be configured directly on the serial console

Wiring

Diagram

 

 

IP Camera Protocol / Webapp Integration

This post is for interested who want to create a desktop or web software to control IP cameras.

Reverse engineering was made in a Chinese IP camera (the image below)

Features:

  • Powerful high-speed video protocol processor.
  • Optimized MJPEG video compression for transmission.
  • Multi-level users management and passwords definition.
  • Embeded Web Server for users to visit by IE.
  • Support wireless network (Wi-Fi/802.11/b/g)mobile, two way audio.
  • Supporting Dynamic IP (DDNS)and UPnP LAN.
  • Giving alarm in cause of motion detection.
  • Support multiple network protocols:
    • HTTP/TCP/IP/UDP/STMP/DDNS/SNTP/DHCP/FTP.
  • Support remote system update,Multi-Protocol support and Transportation.
  • Sending the image to your mailbox automatically when the IP CAM is triggered.

Ref: http://www.chantronics.com.au/computers/viewitem.php?productid=204

In this model the web interface is at the port 81. As the IP of this equipment is dynamic, you can resort to the DHCP client list of the router, or run a port scan. In Linux, use:

nmap -p 81 192.168.1.0/24

Accessing resources of camera

Configuration Page
http://IP:81/config.htm

Telnet
telnet IP
Login: root, Pass: 123456

TIPs:

Open source software in Java, which supports integration with IP cameras:
http://webcam-capture.sarxos.pl/

Java FTP Server:
http://mirror.nbtelecom.com.br/apache/mina/ftpserver/1.0.6/dist/
Ref: https://geertschuring.wordpress.com/2015/02/11/how-to-start-a-simple-embedded-java-based-ftp-server/

Protocol


Video Stream

http://IP:PORT/videostream.cgi?loginuse=myuser&loginpas=mypass

Include in Webapp / Html page:

Snapshot

/snapshot.cgi?loginuse=myuser&loginpas=mypass

Request General Settings

/get_status.cgi?loginuse=myuser&loginpas=mypass

Response:

var alias=”IPCAM”; var deviceid=”EST-065556-XXXX”; var sys_ver=”57.2.0.138″; var now=1452435094; var alarm_status=0; var upnp_status=1; var dnsenable=0; var osdenable=0; var syswifi_mode=1; var mac=”00:0C:6C:11:XX:XX”; var wifimac=”00:0C:6C:11:XX:XX”; var dns_status=0; var authuser=0; var devicetype=21037151; var devicesubtype=0; var externwifi=1; var record_sd_status=0; var sdtotal=0; var sdfree=0;

Request Image Settings

/get_camera_params.cgi?loginuse=myuser&loginpas=mypass

var resolution=0; var vbright=1; var vcontrast=114; var vhue=0; var vsaturation=0; var OSDEnable=0; var mode=1; var flip=1; var enc_framerate=10; var sub_enc_framerate=15; var speed=10; var enc_bitrate=500; var ircut=1;

Change Name

/set_alias.cgi?alias=MYNAME&loginuse=myuser&loginpas=mypass

Resolution

/camera_control.cgi?loginuse=myuser&loginpas=mypass&param=0&value=XX
value=0 – VGA
value=1 – QVGA

Image Mirror

/camera_control.cgi?loginuse=myuser&loginpas=mypass&param=5&value=X
value=0 – normal
value=1 – reversal
value=2 – mirror
value=3 – reversal & mirror

FreameRate

/camera_control.cgi?loginuse=myuser&loginpas=mypass&param=6&value=10
value = 1 a 30

Brightness

/camera_control.cgi?loginuse=myuser&loginpas=mypass&param=1&value=1
value = 1 a 255

Contrast

camera_control.cgi?loginuse=myuser&loginpas=mypass&param=2&value=73
value = 1 a 255

Rotate/Move Speed

/camera_control.cgi?loginuse=myuser&loginpas=mypass&param=100&value=X
value = 1 .. 10

Rotate/Move

/decoder_control.cgi?loginuse=myuser&loginpas=mypass&command=XX&onestep=0
Command Center = 25
PTZ_UP=0;
PTZ_UP_STOP=1;
PTZ_DOWN=2;
PTZ_DOWN_STOP=3;
PTZ_LEFT=4;
PTZ_LEFT_STOP=5;
var PTZ_RIGHT=6;
var PTZ_RIGHT_STOP=7;
var PTZ_LEFT_UP=90;
var PTZ_RIGHT_UP=91;
var PTZ_LEFT_DOWN=92;
var PTZ_RIGHT_DOWN=93;
var PTZ_STOP=1;
var PTZ_VPATROL=26;
var PTZ_VPATROL_STOP=27;
var PTZ_HPATROL=28;
var PTZ_HPATROL_STOP=29;

List Alarms

/get_alarmlog.cgi&loginuse=myuser&loginpas=mypass

Clear: /set_alarmlogclr.cgi&loginuse=myuser&loginpas=mypass

var log_text=””; log_text+=”gpio alarm 2016-01-10 15:49:56\n”; log_text+=”gpio alarm 2016-01-10 15:49:09\n”;

References:

 

Flashing ESP8266 on Linux using: VirtualBox + Arduino UNO

Here’s a quick guide how to flash a new firmware on ESP8266.

If you found this page, you probably are having trouble flashing ESP8266 on Linux (like me .. lol)

If you have not tried using the esptool.py tool, I suggest you test before following this guide.

Some important notices:

  • Cheap FTDI module may not work (so we will use the Arduino UNO)
  • You need a 3.3v regulated power supply

Setup:

  • Ubuntu (x64)
  • VirtualBox (w/ Windows XP 32bits)
  • Arduino Uno Rev3 (original)
  • Voltage Regulator (>= 300 mA)

I tested this tool using Wine (wine-1.6.2) and did not work

Hardware Connections:

esp2688-firmware

The ESP8266 needs to communicate via serial (rx/tx) at 3.3V and does not have 5V tolerant inputs,so you need level conversion to communicate with a 5V microcontroller like most Arduinos use. I’m ignoring this warning, but nobody takes any responsibility for what happens if you do. 🙂

In this scheme we are using the Arduino UNO as USB to TTL, it will only work in Arduno UNO or another that uses a seperate chip for usb serial conversion

Note: I tested using a 9V power supply, but it did not work

Firmware:

First thing we need is to download the Offical ESP8266 AT+ firmware and Flasher tool:
https://github.com/espressif/esp8266_at  (click in download)

Tools:

http://www.electrodragon.com/w/ESP8266_firmware_flasher

Download: Current Version FLASH_DOWNLOAD_TOOLS_v1.2_**

You may need to install serial drivers: follow this tutorial or install arduino drivers

Enable USB in Virtualbox:

USB

Configure Options in FLASH DOWNLOAD TOOLS:

FLASHER

Bin                           Address
boot_v1.1.bin---------------->0x00000
user1.bin-------------------->0x01000 (see newest/ folder)
esp_init_data_default.bin---->0x7C000
blank.bin-------------------->0x7E000

Start Download

  1. Click START
  2. Power your ESP8266

You need to first click START and then power on ESP8266

NodeMCU firmware

You can also use this firmware, using only 1 file and setting to the address: 0x00000

Downloading one of these BIN files : Download nodemcu latest firmware

References

https://ukhas.net/wiki/esp8266_firmware_update
http://iot-playground.com/2-uncategorised/35-esp8266-firmware-update