Posts

Showing posts from 2019

Arduino and Raspberry Pi serial communciation

Image
Want to hook up your Arduino to your Raspberry Pi and send data between the two?  Read on! So you have your Arduino robot, or weather station and you want to send data back and forth with a Raspberry Pi?  The hardware hookup is really easy, but we have to configure a few things on the Pi. Hardware connections We'll use the serial UART pins on the Raspberry Pi Zero GPIO for this example, and transfer data from an Arduino to a Raspberry Pi zero, though all Raspberry Pis and Arduinos are capable of this feat.  The UART is a common serial communication protocol comprised of two pins labelled, RX (receive data pin) and "TX" (transmit data pin).  Wiring is easy - hook up the desired RX pin on the Arduino to the Raspberry Pi TX pin, and the Arduino TX to the Raspberry Pi RX pin.  As always, make sure you connect the ground line  between the Arduino and the Raspberry Pi.  If the particular Arduino model you are using is powered by 5V (find out by measuring the voltage on the

PS2 controller as a radio controller!

Image
Turning a PS2 controller into a wireless radio controller with Arduino Mini and an nRF24l01 radio module I have previously described a project to transmit PS2 controller signals by radio .  The project featured an Arduino Nano that read the PS2 signals and transmitted them with an nRF24l01 module.  Recently I have been inspired to incorporate the battery, charging circuit and Arduino right into the controller - heavily inspired by this project here:

Using the NodeMCU ESP-12E board with Arduino, MicroPython and Lua!

Image
Many ventures into the world of the ESP8266 chip and making Internet of Things devices would do worse than to start with the NodeMCU ESP-12E board.  I started my journey with the powerful but stripped back ESP-01S board - useful for projects such my IR-Egg and cat litter tray Twitter bot where space is an a premium, and very few GPIOs are required.  However I have recently got my hands on some NodeMCU ESP-12E boards and I'm enjoying the relative abundance of broken out pins, the builtin USB with 5V --> 3.3V conversion and programming over the USB.  So far I have used the ESP-12E boards in a couple of small projects, namely as a SPIFFs HTTP file server and as the reciprocal HTTP client . The board has a whopping 4 Mb of flash memory available, and an embarrassment of pins - I feel spoilt!

Getting started with the Pro Micro Arduino Board

Image
This is a brief guide to getting started with the Pro Micro Arduino Board (Atmega32U4) - not to be confused with the Pro Mini (which utilises the Atmega328P)!  Note that the Pro Micro board comes in two flavours/flavors - 5V @ 16 MHz and 3.3V @ 8 MHz, so make sure you know which you have before getting started.  It should be indicated on the bottom silkscreen of the bottom, or you could take a voltmeter and measure VCC against GND - it will be either 5V or 3.3V.

ESP8266 as an HTTP client

Image
I recently blogged about how to setup an ESP8266 as a file server , in particular using SPIFFs to store the files.  But how can we retrieve HTML and general files from a web server?  In this post I'll demonstrate some code to make a request for a file from a server, then save the results on the SPIFFS on the ESP8266 client.  In terms of implementation, this works very well on a NodeMCU ESP-12E board.  I've also tried it on a ESP-01S board - there is a technical issue writing to SPIFFs within a program on some of the latest versions of this board.  There is a fix however, discussed at the end of this post.

ESP8266 as a SPIFFs File Server

Image
How to setup an ESP8266 board as a server using SPIFFs This how-to guide describes using an ESP8266 chip to setup a server to do what servers do... serve files!  If you want to know how to retrieve files from a web server, see my post on using the ESP8266 as a HTTP client .  Although HTML and other files can be contained within the program itself ("sketch" in the Arduino parlance), it is inconvenient, especially if you want to deposit images on the ESP-board, or change your files in and out easily.  The solution is use to SPIFFs, a file system that uses the on-board SPI flash chip, which can be written directly from your computer (and read and written from programmatically within your sketch too).  The amount of memory will vary depending upon the board in question.

Litter tray TwitterBot - BeemoPoops!

Image
The Internet of cat litter trays - TwitterTray The world almost certainly doesn't need an internet-enabled litter tray that sends an amusing tweet every time my cat uses it.  But the world wasn't consulted, and got it anyway.  Follow Beemo the cat's poops at  https://twitter.com/BeemoPoops . Above:  "You've put a Twitter-what on my litter tray now?!" - Beemo, the cat in the hat.

Random number generation on the ESP8266

Image
Soooo random! For an ESP8266 project that sends randomised tweets, I need to use a random number generator.  In such a deterministic system such as a digital computer however, true randomness is hard (impossible) to come by, so we must settle for a pseudo-random number - that is a number that is part of a seemingly random sequence and is generated algorithmically from the previous number(s) in the sequence.  It is good enough for our purposes.  The simplest implementation of a pseudo-random number generator (PRNG) is a Linear Congruential Generator , i.e. X n+1 = (aX n + c) mod m

Tweeting from the ESP8266

Image
Other blogs have covered how to send data from the ESP8266 to a web server.  Sparkfun suggest a few services ( here ).  I've started playing around with ThinkSpeak .  The platform is great, and allows you to react to and visualise your data.  I have been looking for a way to post to Twitter from the ESP8266 for a project I've started working on and found that there wasn't a wealth of information.