arduino, Esp32, Uncategorized

ESP32 is nice, but…. too wide.

In one sentence? TOO FUCKING WIDE. It does not fit any breadboard I have.



Running a 5V 5mw 650NM laser from Arduino.

Simple as shit, but as I haven’t found it….

It’s almost the same as the “blink” example from Arduino IDE. One just needs to change the pin (I use ~11), and use analog write instead of digital.

Follows the code:

int laser = 11;

void setup() {
 pinMode(laser, OUTPUT);

// the loop function runs over and over again forever
void loop() {
 analogWrite(laser, 20); // 20:enough. 100: hurt your eyes
 analogWrite(laser, LOW);
 delay(500); // cool it down



Robot car controlled by iPhone using Blynk and NodeMCU.


I created a simple app on Blynk with 4 buttons connected to virtual Pins.

See how to install and run Blynk here.Then, just connect those buttons to virtual pins, like this:


Forward: V0, Backwards: V1, Right: V2 and Left: V3. It look like this:


Got a token for the project and used on the following file on your Arduino IDE.

 * This example runs directly on NodeMCU chip
 * using the Blynk platform and mobile application.
 * Change WiFi ssid, password, and Blynk auth token to run :)

#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#define RightMotorSpeed 5
#define RightMotorDir 0
#define LeftMotorSpeed 4
#define LeftMotorDir 2

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
char ssid[] = "MyWifi";
char pass[] = "MyWifiPassword";

void setup()
 Blynk.begin(auth, ssid, pass);

 pinMode(RightMotorSpeed, OUTPUT);
 pinMode(RightMotorDir, OUTPUT);
 pinMode(LeftMotorSpeed, OUTPUT);
 pinMode(LeftMotorDir, OUTPUT);

void loop()

void halt()
 digitalWrite(RightMotorSpeed, LOW);
 digitalWrite(LeftMotorSpeed, LOW);

void forward()
 digitalWrite(RightMotorDir, HIGH);
 digitalWrite(LeftMotorDir, HIGH);
 digitalWrite(RightMotorSpeed, HIGH);
 digitalWrite(LeftMotorSpeed, HIGH);

void reverse()
 digitalWrite(RightMotorDir, LOW);
 digitalWrite(LeftMotorDir, LOW);
 digitalWrite(RightMotorSpeed, HIGH);
 digitalWrite(LeftMotorSpeed, HIGH);

void right()
 digitalWrite(RightMotorDir, LOW);
 digitalWrite(LeftMotorDir, HIGH);
 digitalWrite(RightMotorSpeed, HIGH);
 digitalWrite(LeftMotorSpeed, HIGH);

void left()
 digitalWrite(RightMotorDir, HIGH);
 digitalWrite(LeftMotorDir, LOW);
 digitalWrite(RightMotorSpeed, HIGH);
 digitalWrite(LeftMotorSpeed, HIGH);

 if (param[0])

 if (param[0])

 if (param[0])

 if (param[0])

Wiring up the shield to the engines and battery is straightforward. Left wheel is “Motor B”, right wheel is “Motor A”, and power goes to “ESP Power”. If you insert a jumper on the “shortcut” on the VIN and VM pins, it will power the NodeMCU from the same power source.



Assembling everything together, the thing comes out like this (click to zoom):

And it runs well:

Right now, this is a dumb machine. I will install some intelligence on it pretty soon 🙂 Besides, I will play with different wheel options and maybe a servo on the front.


Cheap Chinese Arduino clones or Serial-to-USB with the CH340G / CH341G on MacOS Sierra

I got an Arduino UNO clone for around 3 euros on Aliexpress. It’s like 8 times cheaper than the original one, and, unlike the piece of shit that the Orange Pi is (check my previous post), the quality of this clone is the same as the original… Almost.


An AlmostDuino 🙂 For 3 bucks instead of 25, who is complaining?

It uses the same Serial-to-USB CH340G chip that you can find on the USB-Serial module. Therefore, they are not directly supported on MacOS Sierra.

fvkpqkzitkljgsg-largeSerial-to-USB module.

If you google around, you will find a driver.. That kernel Panics MacOS. Seriously, it’s been the first kernel panic I’ve seen in YEARS on Mac OS.

Well, the driver is here: you have to reboot after that. It will appear at your Mac as a /dev/tty.wchusbserialXXXX and the Arduino will work as intended. Or the serial adapter like the one you see above. Both use the same driver.

Have fun!


Orange Pi Lite and the value of communities

I am a subscriber of It’s a great way to get into some easy projects that you would probably not do by yourself if you would have to buy everything from Aliexpress and wait 3 months for your shit to get home. It’s pretty much like hellofresh for electronics.


Typical hackerboxes’ contents.

September’s box came with an Orange Pi lite – a supposedly contender on the single-board computers.

I’ve read about that before, as I read about many other single-board computers which appeared recently. They all claim to be better than the Raspberry Pi in one way or another. Or cheaper. Or both.

In fact, I have a C.H.I.P. $9 computer, and it works great – if that shit had HDMI, I would buy a dozen of them. Or…. maybe not.

C.H.I.P. – the worst name ever to google for. But it has DOGE-quality control. Seriously.

But I digress.

Why people use those single-board machines? Basically because they are cheap as fuck and because it’s so easy to use their GPIOs. Want to attach a small screen? 2 and a half bucks and a download. Pretty much everything on the Raspberry Pi is like this.

That orange pi claimed full compatibility with Raspberry Pi. Well, it does not. The GPIOs are different, the libraries are different (and not so available), the whole Linux distribution is different. In fact, it sucks to install ANYTHING on it. Reviews after review they tell how this machine sucks. How finicky it is with SD cards and power sources, how it doesn’t tell you shit before the boot, how slow it actually is, etc etc.

I remember that took me a week to make mine to boot. Then, this week, I decided to install RetroPie, a Linux distribution with emulators in mind, and play some Super Mario.

Big Mistake.

After spending hours downloading and copying the image to the SD card and not having ANY idea what the fuck was going on (the Orange Pi does not turn on the screen, a LED, nothing, until it successfully boots), I decided to go for a serial console.

Yep. I am using a serial console in 2016 because a 2016 computer can’t bother to light a fucking led when it’s on.

Interestingly, the Orange Pi’s hardware can be so great in some aspects, and suck in others. For example, it has Wi-Fi, IR, a proper reset button, it’s quad-core, etc etc. And it costs 12 bucks.

To connect the Orange Pi to my Mac, I used a USB-to-Serial (isn’t usb serial already?) CH340. This:


Welcome to 1962. Here is your RS-232 connector from a Macbook Pro to a Quad-Core computer made in 2016 for US$ 12.

The Orange Pi has 3 pins for RX, TX and GND for a serial console, which you connect to this little thing and then to the Mac. Except that you need a driver for it, and the official one makes the Mac go bananas. Really. I haven’t seen a Mac have a kernel panic in almost 10 years. But there is a fix for mac kernel panic.

After that, it’s a matter of running a

screen /dev/cu.wchusbserialXXXXXXX 115200

Where XXXXX is whatever in your computer. After that, you are able to see what this piece of crap is doing before it shows anything on the screen.

img_3848My OrangePi connected to a Mac via usb-to-serial.

After using this I somehow managed to make this crap boot. But not with the RetroPie I wanted, but with the same vanilla Armbian (Debian for arm – got it?) that I had before.

And I don’t know what to do with it.

  • It’s slow as fuck.
  • It needs its own stupid power cable. It’s the worst thing about the whole machine. Seriously.
  • It’s REALLY finicky. You tell it to reboot? Good luck! It will certainly stop responding, but sometimes it can reboot. Mostly not.
  • Setting up wifi is a real pain in the ass.
  • It overscans on my HDMI tv. Their response? Get a new TV.
  • Do I need this stupid Wi-Fi antenna? It’s slower and worse than the invisible one from the Raspberry Pi 3.
  • I can’t have ANY idea about what’s going on until the machine is in the middle of Linux boot. If it worked fine, that wouldn’t be a problem, but it does not.
  • The manufacturer does not provide even their own Linux image!
  • GPIOs totally different from Raspberry Pi. No libraries work without being adapted.
  • Community support? It exists, but it’s small and a best-effort thing for a machine whose destiny is to be forgotten.
  • If I want the nintendo emulator, I need to configure it by hand as if this is Slackware in 1994.

I was reading some forums, where some nerd said that “If you want a great machine, buy [whatever], if you want marketing, buy a Raspberry Pi”. And I was thinking about that.

To run a PWM engine on the Raspberry PI, I have to import pwm in a python program. To use an SSD1306 OLED screen, all I need to do is “import SSD1306”. And so it goes.

To find solutions about your problems, there are literally thousands of sources, and literally millions of people using Raspberry Pis. All your questions are mostly answered.

After using this Orange Pi, I came back to one of my Raspberry Pi Zeros. Where EVERYTHING works.

And I got so happy to have this wonderful ecosystem. Where a kid goes from back-street kid to Ph.D student thanks to the Pi.


Raspberry Pi Proto HAT

Following the previous post, you can see that I had a ribbon cable from my Pi to a T-Cobbler to a breadboard. All dangling in my kitchen. Something like this, but way less elegant:


So I found a Raspberry Pi HAT that serves as a breadboard. This is how my Pi looks like with it and the thermal sensor from the previous post. The plastic cover under was drilled to fit the screws, so the Pi is protected from both sides:

Photo 29-09-16 23 33 31.jpgPhoto 29-09-16 23 33 51.jpg

Pretty cool, eh? I think that everybody should have at least one of his/her Raspberry with one of those attached.


  • It’s right on the Pi: no ribbons, no weird positions, no bullshit
  • Cheaper than a breadboard (buy for 2,26€ on aliexpress). In fact, cheaper than a plastic cover for the Pi!
  • All signal pins are in one line. Way easier to find.
  • No need to connect ground, 3v or 5v: they are all on nice locations. (see next image)Unknown.jpeg

Disadvantages over a breadboard:

  • You can have way more space on a breadboard, although if you look at the first picture with the ribbon, a mini breadboard with a cobbler provides even less space.
  • The holes are not as tight as a breadboard, and won’t hold your wires. You turn this upside down and they all fall. They have no problems with contacts, though.
  • Can’t power it from an external source: the 3v and 5v rails come directly from the Pi. No motors with this one.
  • Needs soldering for the 40 GPIO pins.

I am not making money out of this. Just wanted to share because it’s so useful, practical and cheap. This should come standard with them, really.


Temperature sensor

One of the things I always wanted to do with my solar rig is to correlate temperature with energy output. For that, I got one of these:


DHT11 temperature and Humidity Sensor – 77 cents on AliExpress.

It is REALLY simple.

Pin 1 3.3V
Pin 2 Signal+10k ohm resistor to 3.3v
Pin 3 Nothing
Pin 4 Ground

It is said that it can withstand 5.5v – with me it didn’t work.

If it helps, that’s how I have it, but I use GPIO4. It’s the same. Circuito-Raspberry-Pi-DHT112.png

IMG_2863.JPGThis is my Pi2 connected to the Solar Panels.

In order to read it, I cloned Adafruit’s git repo and installed it

git clone
cd Adafruit_Python_DHT
sudo python install

I needed to upgrade Raspian from Wheezy to Jessie (which I should have done a long time ago anyway) in order for the code to run without root. After that, the code is this:

import sys
import Adafruit_DHT

humidity, temperature = Adafruit_DHT.read_retry(11, 4)
print 'Temp: {0:0.1f} C Humidity: {1:0.1f} %'.format(temperature, humidity)

And that’s it. I run this on my cron script that sends this data to