Uncategorized

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:

gfd6-500x500.jpg

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.

Advantages:

  • 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.

Advertisements
Standard
Uncategorized

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:

dht-11.png

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 https://github.com/adafruit/Adafruit_Python_DHT
cd Adafruit_Python_DHT
sudo python setup.py 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:

#!/usr/bin/python
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 initialstate.com:

https://app.initialstate.com/embed/#/tiles/75P10PHsOP8lP5wwHQFtz7MqzmJowC9t

Standard
Uncategorized

Hackerboxes #10: Orange Pi

So, I subscribed to hackerboxes (link). It’s a goddamn amazing idea. It’s… okay.

I saw the amazing things they shipped on their past boxes, and I thought I would give it a go.

Then I got… Box number 10.

Someone made an unboxing:

The microsd to usb does not work. At all.

The microsd card is fake.

Took me three days of trying to make the thing to boot. I can take a Raspberry Pi Zero with a new microsd card to boot in five minutes, so I have no idea what it’s up with this one.

It might be the SD card. But it works with other machines.

This thing takes a proprietary connector, and I hate it. And it’s finicky . That’s the deal breaker. 99% of the time it does not work with normal USB connectors.

It does not deal with overscan, so it’s useless for me. img_2839

Apart from that, it’s a Raspberry PI 3 from a third of the price. It is fast! But… I would not bother.

Can’t wait to have the next one. And hope it’s less crap.

Standard
Uncategorized

Showing letters on a 8×8 dot matrix display with only 3 GPIO pins on Raspberry PI

I have been playing around with connecting electronics to the raspberry pi, so I bought the Sunfounder SuperKit v2 for Raspberry PI. It’s a great value and comes with everything you need to begin playing with the PI and electronics. Really recommended.

711vaK78H0L._SL1000_

The book shows what to do with each of the main components (engine, display, etc). One of the components I really like is the Dot Matrix display. On their example, it is shown how to use the two shift register micro controllers in cascade, to be able to control the 64 LEDS using just three outputs (bits) from the Raspberry. As you can see on their schematics, it uses GPIO 11, 12 and 13:

4.png

With it, they have shown how to display one line or column at a time. Which is hardly what you want with this thing. In fact, they give you very unfriendly examples on how to display. Their code just shows you this:

code_H = [0x01,0xff,0x80,0xff,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff]
code_L = [0x00,0x7f,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f]

Full code on Sunfounder’s GitHub

So I decided to improve. Taking that program, I created a 6×8 binary representation of the alphabet, and I show one letter at a time. So, one can just type

display_phrase("This is a test 0 0 0") # Zero shows a heart :-)

And it will show exactly this.

My version of the code also improves on the fact that it is easier to understand how to draw with mine: You just draw in binary, from right-to-left, an 8×8 square and it will show it. The value zero is a pixel on, 1 is a pixel off.

alphabet= {'A': [0b11110011,
                 0b11101101,
                 0b11011110,
                 0b11011110,
                 0b11000000,
                 0b11011110,
                 0b11011110,
                 0b11011110], ... }

A letter A. Easy to draw like this, isn’t it? 🙂

It also always cleanup the GPIO values, among other things. You can fork my code from GitHub.

Standard
Uncategorized

When governments fuck up, science goes down the drain. Then, next generations suffer (TLDR: Brazilian academic internet will be down)

This happens everywhere, every time.

I have seen it in Venezuela. The “socialist” government fucked up pretty much any academic research, naming it “capitalist”. Seriously, what is more socialist than sharing knowledge?

Now, after the white coup that took out the president in Brazil, the former vice-president became president. Yep, from the leech party. THE LEECH party. They are where money is. Since forever. So, yep, it’s a coup. But I digress.

Now that the LEECH party (should I say neo-Malthusianists?) took over, they decided to take some initiatives more…. as they say, “in order to make the country grow again” (Make america great again, anyone?). So, they are going on the classic liberalism of the 18th century: cut costs, small state, less regulation for workers, all the shebang. Without really thinking about future consequences.

The coup president wanted a PASTOR as the Minister of Science and Technology. Then after the backlash. he decided to fuse such ministry with the one for the one for communications. You know, the shit dominated by telcos everywhere. So, now, brazil has all science as a vassal to the worst companies of the continent.

Their first act: cut internet to Academia. Because science is not essential.

You know what, Brazilians? You deserve each other. You wanted it. I am gone for good.

Btw: news in portuguese: http://educacao.estadao.com.br/noticias/geral,rede-nacional-de-pesquisa-fica-sem-verba-e-pode-sair-do-ar-em-1-2-mil-campus,10000065814

Standard
Uncategorized

Connecting a second battery? Not so fast…

I have connected the BMW battery to my grid. First alone, then in parallel with the one I have been using so far. The results were disappointing.

This is the initialstate.com’s graph about the uptime after I connected just the BMW battery on the solar grid, and with both batteries:

Screen Shot 2016-07-29 at 10.38.44.png

The pink line is uptime, yellow is temperature, the blue is a event triggered at every reboot.

As you can see from the last side, uptime was high (about 10 days, could have been longer, I rebooted it for some reason). After that, the machine started to restart constantly. Then, at the end, one can see that the uptime started to get smaller and smaller.

I am not sure why yet. My speculation is that, because I made in the middle of the night, both batteries were not exactly at top charge when I connected the Solar Panel controller.

This solar controller requires batteries to be fully charged when connected to it (that is, during its boot). This is to avoid overload, probably, so it will only keep charging the batteries up to this value.

So, as I connected the batteries to the controller in the middle of the night, took a low value as its top and didn’t charge them.

Living and learning, as the saying goes.

Next step? To fully charge both batteries (with a conventional electric charger) and only then connect them to the solar controller.

 

Standard
Uncategorized

FINALLY! A PROPER VIEW OF MY MEASUREMENTS! Thanks Initialstate.com!

After I found out (with the amazing support from initialstate.com, and correcting a previous comment, it is indeed possible to send events from the past. You just need a proper JSON request).

So I got all the data from March until now. I will devise a way to send the data I have gather since last winter as well. eventually. But, thanks to initialstate, I can see the difference a slightly better solar controller makes:

Screen Shot 2016-07-20 at 00.14.41

This is an uptime graph. The Y scale shows how long the machine has been up. The higher, the better. As you can see, it was pretty uniform until around may 15. That is when I changed from a shitty 6€ solar controller (never buy that shit) to a 12€ slightly better one (aliexpress link).

What you see is that I rebooted the P from time to time after May 15th, but just because I wanted to. The PI can run indefinitely with the amount of solar panels, batteries and cheap controller I have running it. Imagine what I can do with the second battery and a proper controller….

Standard