Using the CJMCU 8128 Breakout Environment Sensor Board

The CJMCU 8128 breakout board includes a great trio of environment sensors that pretty much cover all the bases when it comes to sensing your local environment and has a few overlaps especially with temperature. I’ve only seen it avialable so far at Baggood.com.

In the picture below you can see each of the three sensors labelled:

CJMCU Module Labelling

What’s on Board

These relatively cheap sensors include 3 main modules - with links to their data sheets:

Its worth mentioning the temperature values returned by each of these sensors are all different and sometimes by a few degrees so you could either use all 3 and pick an average of the 3 or pick the one which has the smallest reported variance according to its datasheet. Which at the time of writing would be the HDC1080.

Having said that I’d still recommend checking the temperature’s reporting against other sensors you may have and deciding for yourself.

Hooking up to a Raspberry Pi 3

You only need to hook up the 5 of the 8 pins provided for all 3 sensors to work on a Raspberry Pi connected using the i2C bus with pins VCC and GND being self-explanatory. Although VCC should go to 3.3V supply pin on the Raspberry Pi. The SDA and SCL pins shoyuld go to the corresponding SDA/SCL i2c GPIO pins. The last pin to notice is the WAK pin which according to the documentation should go to a free Ground pin.
CCS811 datasheet[PDF]. The WAK(E) pin is used to wake a sleeping sensor from a hibernated low-power state. To make the module sleep you would put logic high to pin WAK and to wake the module you’d put logic low or Ground to that pin. As the whole breakout board uses only a tiny amount of power anyway and this post is about being connected to a Raspberry Pi I’ve chosen to hook up the WAK pin to GND to keep it permanently awake.

If you were using this on an ESP32 or ESP8266 where you wanted to take advantage of low power states then its worth looking further into this by checking the datasheets for each sensor.

See below for a photo of one connected and working with my home setup.

CJMCU wired via i2c to Raspberry PI

Prerequisites

Required Libraries

I’ve created a repo with an example that uses all three of the onboard sensors based off submodules of existing libraries that are out there for each. Adafruit have Python libraries for the CCS811 and BME280. With SDL having an example Python script for the HDC chip.

You can reach the repo with an example that combines all 3 of the submodules here.

There are other libraries you an use as the above uses Python mainly but especially in the case of the BME280

That library is what I am using with my own IoT setup at home with the small change of including and using Artik Python libraries to send my data to Samsung Artik for displaying the data in a dashboard format.

Ensuring the Breakout is Connected Correctly

You can run the i2cdetect command with the following arguments:

i2cdetect -y 1

You should get the following output:

1
2
3
4
5
6
7
8
9
0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- 5a -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --

This stage is important as the default address for the BME/P 280 is 0x77 but in the CJMCU board it is as you can see above 0x76. Thankfully the Adafruit library comes with the ability to set the address on instantiation of the sensor class. See below…

1
2
3
4
5
6
sensor = BME280(
t_mode=BME280_OSAMPLE_8,
p_mode=BME280_OSAMPLE_8,
h_mode=BME280_OSAMPLE_8,
address=0x76
)

Web Dev Tools? What About Web Design Tools

Great video from one of the devs responsible for Firefox’s Dev Tools which
I now much prefer using over Chromes Dev Tools.

Check out the video below for info on the future of Dev Tools and a call to arms
for extension developers to speak up about what they’d like to API-wise to
hook into Firefox Dev Tools.

Some of the links to thing mentioned in the video are:

https://www.youtube.com/watch?v=oGobLmA_WVQ

MQ Gas Sensors List

Here’s a not entirely comprehensive list of the MQ gas sensors often seen being used in Arduino smoke alarm or breathalyser projects. Like mine for example. I also have 2 of these set up as analog sensors on my Enviro pHat connected PiZero. One being an MQ135 and the other MQ-2. Not sure why I need to keep an eye on gas leaks in the living room but you never know! MQ-135 may make a bit more sense though to be honest it keeps a pretty still 0.41 value for the past several days. I may replace it with the optical Sharp GP2Y1010AU0F dust sensor as a general air quality indicator.

  • MQ-2 - Methane, Butane, LPG, smoke
  • MQ-3 - Alcohol, Ethanol, smoke
  • MQ-4 - Methane, CNG Gas
  • MQ-5 - Natural gas, LPG
  • MQ-6 - LPG, butane gas
  • MQ-7 - Carbon Monoxide
  • MQ-8 - Hydrogen Gas
  • MQ-9 - Carbon Monoxide, flammable gasses
  • MQ131 - Ozone
  • MQ135 - Air Quality (CO, Ammonia, Benzene, Alcohol, smoke)
  • MQ136 - Hydrogen Sulfide gas
  • MQ137 - Ammonia
  • MQ138 - Benzene, Toluene, Alcohol, Acetone, Propane, Formaldehyde gas, Hydrogen
  • MQ214 - Methane, Natural gas
  • MQ216 - Natural gas, Coal gas

While you’re here you may find the following tutorial on how to read MQ sensor values using a Raspberry Pi and how to convert its analog data output to a digital output for the Pi.

Trying to Box My First Rakit

This project has been a long tiume inclubating as a draft as I kept making adjustments and changes. Eventually I thoughjt I neeed to publish this thing as its been under draft for 5 months now. So the APC was finished in December but the box and blog was finished today.

What I Ended Up With

A Rakit Atari Punk Console kit with Depth & Pitch control packaged into an old JVC earphones box with a PP3 battery holder superglued to the back. With an all important sticker!

Rakit Atari Punk Console in Project Box

How I Found What I Wanted (DIY Noise Makers)

I decided to get into DIY electronic kits after seeing the huge number available on BangGood.com. Before I came to Rakits I’d made DIY clocks with temperature and light sensors, multiple failed radios (they’re my weakness), power supplies, speaker kits, etc.

But it didn’t take long for my industrial music loving brain to come up with the following important formula:

DIY Electronics + Like Noise = DIY Noise Making

So then I went hunting for noise making devices I could hook up to my speakers or just make noise with. I remember an interview with someone from Throbbing Gristle where they openly admitted knowing not a single thing about making music but they enjoyed making noise. Having owned an electric guitar for about 6years and still not being able to get past 3 chords I sympathised and wanted to make noise too but with someth9ing I’d built myself.

Coming Across Rakit

I came across my first Rakit first via eBay. Their eBay store has the full collection but they have their own site with tons of options and a great informative blog that’s well worth checking out.

My first Rakit was the Atari Punk Console which did exactly what I wanted - make noise! I also got a sequencer - that was a mistake! Too soon! It ended up with the LED’s on the wrong side, all messed up and I gave up part way and resigned myself to a new one form their site!

Don’t be overconfident and take the advice on their sites shop for each item as to how difficult they are - also be worth checking out the Assembly Guides which are there too.

Building a Box for my First Rakit

Having done a lot of kits that came with their own box I felt my first rakit needed one but only something simple and preferably recycled form the multitude of bits and pieces of cruft I have lying around.

An Old JVC earphones box

At first I thought I could fit the battery and circuit into the box and be donbe with it but I lacked a few things such as…

JVC Earphone Boxas a Project Box
  • a drill.
  • drill bits for small holes and big holes.
  • a ruler
  • everything to make a proper project box work!!

So I bought my above list of atefacts online while constructing my APC. I set about creating padding for the base where the Rakit would sit

Insulated Padding Bottom Stuck With Double-Sided Tape

At first I was planning on using the battery clip cable that came with the kit but after finding out that my supergluing it to the PCB and melting the insulation (see pic) to it that I needed to find a replacement and reover the situation. I’d recently bought a job lot of about 25 PP3 battery holders so I superglued one to the back after drilling holes for the terminals to slide into that would come up behind the PCB inside the case. See pictures below…

Notice how the battery wire near the PCB looks melted and merged? Choosing holder over clip

You don’t have to have an electric drill for any of this work to be honest. I did end up using an electric hand drill for the POT holes but I could have used the hand drill you see in the picture which costs tuppence ha’penny from Amazon or your local hardware shop for about £600 + VAT (and they wonder why local shops go out of business :/ ).

Drilling holes for battery holder terminals

Although there were screw holes for the battery holder (4 in total as you can see) why waste the time and screws when a simple bit of superglue would work just as well.

Gluing the battery holder

I created the grey padding in this photo using the cut up chunks of an old gas soldering iron taped together using insulation tape then with double-sided sticky tape placed on the bottom to keep it stuck in place. Sorry - were you expecting me to say I 3D-printed something? Sorry - I’m pretty low tech when it comes to building things like this. Be prepared for more when I post about other hacked electronics projects.

Insulated Padding Bottom Stuck With Double-Sided Tape

How Did It Turn Out?

Not amazing but OK as a first attempt at putting a DIY electronics kit in a recycled project box. It gave me a MUCH greater respect for peope who build hardware boxes for electronics and taught me a great deal of what needs to be done to improve on my next adventure.

I thought a simple ruler, a few drill bits, and a craft blade would be enough. Little did I know the sheer complexeties and questions it throws up along the way - especially when not planned. Such as me having to put the POTs on the PCB into the holes before closing the box. Then finding it didn’t align the output hole with the box hole. Also noticing that the POTS didn’t align horizontally (see below).

Notice how the finished projects POTS don't align?

Using superglue the wrong way and finding it melts wire insulation. A lot was learnt (see below). I’ve since bought another APC and will likely break out every single resistor not just the usual POTS as I noticed that changing the resistances in paralell gave different sounds. So I think there’s more options there. A whole array of POTS in a long line with options to chain them into a Mega Deluxe Atari Console. I also got the Deluxe APC to do the same with. This time I’ve got better boxes and I’ll use what I’ve learnt here on the new fully broken out versions.

Its Important To Keep a Clean Work Area

Always keep a clean work area

Notice I’m currently working on the drum kit. This project has given me a whole new insight into how complicated it must be to CAD and produce a case. To me the drum case seemed relatively simple until I had to produce my own project box!

But no seriously you should always keep a clean work area to make sure projects components don’t get mixed up and solder standing or under a desk so you don’t drop hot solder on yourself.

What I Learnt

  • Plan and plan some more.
  • Measure once, nmeasure twice, cut/drill, measure thrice.
  • Be prepared to make mistakes.
  • Superglue makes wire insulation melt and potentially merge and short circuit wires.
  • Quick component testers are sometimes faster than a multimetre at giving you a resistor or capacitor value.
  • Making noise is awesome.
  • The continuity tester on my multimetre is great.
  • I’m not very good at making project boxes look good.
  • I have a renewed respect for the people at Rakits and for their designs and the work that goes into them. It ain’t easy!
  • I like stickers!!
  • Don’t solder over your crossed legs.
  • I’m a sucker for sweets!
  • It’s possible to fiddle with the the boards components in paralell to make noises in different ways. Such as sticking POT terminals over a resistor and you get weird extra/other noises. As mentioned this will be the core of my next project with an APC.

Where to Get Your Maker/Hacker Electronics in the UK

If you’re anything like me then programming probably isn’t your only hobby and you try a fair few electronics projects at the same time. Two of my favourite Linux Magazines (Linux User & Developer and Linux Magazine) either have a regular Raspberry Pi sections OR they have tutorials about hacking Ardiuino’s and related chips (ESP8266, ESP32 [Lua, MicroPython, C, etc]) in some way. There’S even a hugely popular UK magazine called MagPi which caters to people interested in hacking Raspberry Pi’s or Pi Zero’s.

This is my personally built up list of decent sites for electronic kits, components and hobbytronics:

Chinese Suppliers

BangGood Logo

Gadgets and Electronics

BangGood.com

I’d make sure you’re not buying a trademarked/patented device suchh as the Teensey’s which have official distributors but their ESP8266’s are 10% the price of buying UK versions for the same equipment. For example at time of blogging here’s BangGood’s NodeMCU ESP8266 selling for £3.38. At Pimoroni they’re selling for a whacking £12 before delivery. Did I mention Pimoroni charge delivery on top whereas BangGood are all free delivery? The only disadvantage being you have to wait a week instead of a few days. Check BangGood before anywhere else if you want DIY electronics kits, Arduinos, ESPX chips, etc. You really can make a MASSIVE saving. In fact BagGood are so much cheaper that for still less than what POimoroni charge you can get an ESP8266 chip with a tiny OLED screen embedded on the board for £7.66!!!

As a sweetener here’s a few coupons they have going at the mo:

GearBest

Tending less to the smaller components and more to gadgets its still worth checking this company out as they are one of the Chinese providers that offer massive discounts on expensive western imports.

Raspbbery Pi/Arduino:

The Pi Hut Logo

The Pi Hut

I have it from the horses mouth that if you want the latest and greatest of DFRobot’s cool newest gadgets in the UK then these guys will have it first. I’m a HUGE fan and can easily spend hours just browsing their Maker section. I also have the afformentioned Beetle and μHex Controller from them.

ModMyPi Logo

ModMyPi

Specialises mainly in Pi’s and doesn’t deviate much into the general hacker space like the Pi Hut which has its own maker area. ModMyPi can also be a bit expensive. Havoing said that they are oftenb the first to release things like Google’s AIY or Raspberry Pi robots.

Pimoroni

Has a really good selection of both official Pi and Arduino equipment as well as being one of the best Ada Fruit supplier in the UK. So if you’re looking for an AdaBox (personally I think they’re a rip off) then you can’t go far wrong with Pimoroni. But be prepared - they charge heavily for what you get.

In fact I've compared prices before between the 3 major sites so far mentioned and found prices variances of £5-20 for a small product. But I've noticed in recent months a convergence of prices which concerns me as they are the major suppliers for makers at the moment. Am I being paranoid thinkning they're price fixing or just watching each other and price matching? Nowadays I find myself split between who charges the most for delivery as all the prices are exactly the same. Or I use one of the Chinese sellers or general electronics suppliers

Maker/Hacker/Hobbyist Electronics

These are great for finding custom kits or something a bit different. These always fill a niche and I always have a browse now and again to find something new and cool to work on.

BitsBox

They do lots of the most commonly used components but also have a great little selection of DIY kits for things like amplifiers, FM Bugs and much more. What I also like is their great collection of easy to navigate enclosures or project boxes. Some coming with battery doors making them really handy.

Rakits Logo

Rakits

I love these guys so much! One of my favourites for DIY sytnth kits! They were one of my first forays into noise making projects and I discovered them via their ebay shop. I already have one oif every one of their kits but plan on buying extra of all of them to create breakout versions to put in project boxes I’ve bought from BitsBox to create my own little synth playground with sequencers - the works.

Hobbytronics

Not a company I’ve used much for except the odd kit not available elsewhere. Always worth a check out though to make sure you’re getting the best deal when checking other sites.

Conrad Electronics

Only recently discovered these guys and I’m already super impressed by their sheer selection of DIY project kits for electronics enthusisasts that covers Arduino’s, Pi’s and every other type of maker and hacker type out there. Check out their kit section to get an idea of what I mean.

Electronic Components

I recommend these only if you know exactly what you want and have a code for an IC or transistor. As they have so many products its difficult to navigate the search to find individual products.

Farnell Element 14 Logo

Farnel/Element14

These are one of the main official distributors of Raspberry Pi’s as designated by teh RPi foundation. So you don’t just get resistors, capacitors and whatnot here. You can get practically anything & everything yoiu want from these guys but the prices are a biut hefty unless you’re buying in bulk. Its also a pain sifting through the sheer quantity of components for exactly what you need. Come prepared with exact component numbers and types.

CPC Electronics Logo

CPC

Actually part of the Farnell group so you’d expect the prices to be the same. Except they’re not. I think one is mainly for business while the other consumer but you can buy from either and its worth cross-checking both for pricing. Bare in mind they also charge differently for delivery.

Missed Off?

If you think there’s any companies I’ve missed off the list be sure to email me dougbromley @ gmail etc.