Voici la question qui me guide dans mes recherches...

L’appât du gain manifesté par les entreprises supranationales et certains groupes oligarchiques, de même que le contrôle des ressources naturelles par ceux-ci, dirigent l’humanité vers un nouvel ordre mondial de type féodal, voir même sa perte. Confronté à cette situation, l’être humain est invité à refuser d’accepter d’emblée une pseudo-vérité véhiculée par des médias peut-être à la solde de ces entreprises et groupes. Au contraire, il est invité à s’engager dans un processus de discernement et conscientisation afin de créer sa propre vérité par la confrontation de sa réalité nécessairement subjective à des données objectives, telles que révélées par la science, par exemple.

The penalty that good men pay for not being interested in politics is to be governed by men worse than themselves. - Plato

jeudi 3 mars 2016

The Zerynth Framework: programming IoT with Python

Here's some quick notes on what I discovered today on

The Zerynth Framework: programming IoT with Python

Good starting point well written on open-electronics.org

Here we learn of a new firmware that can be loaded on those microcontroller:

Here's some links for those microcontrollers, mostly based on ARM 32 bit.

Here's an example code for blinking 3 leds independently showing the power of Zerynth  multi-treading 
# Initialize the digital pins where the LEDs are connected as output
pinMode(D2,OUTPUT)
pinMode(D3,OUTPUT)
pinMode(D4,OUTPUT)
# Define the ‘blink’ function to be used by the threads
# delayON and delayOFF are optional parameters, used as default if not specified when you call the function
def blink(pin,timeON=100,timeOFF=100):
while True:
digitalWrite(pin,HIGH) # turn the LED ON by making the voltage HIGH
sleep(timeON) # wait for timeON
digitalWrite(pin,LOW) # turn the LED OFF by making the voltage LOW
sleep(timeOFF) # wait for timeOFF
# Create three threads that execute instances of the ‘blink’ function.
thread(blink,D2) # D2 is ON for 100 ms and OFF for 100 ms, the default values of delayON an delayOFF
thread(blink,D3,200) # D3 is ON for 200 ms and OFF for 100 ms, the default value of delayOFF
thread(blink,D4,500,200) # D4 is ON for 500 ms and OFF for 200 ms

To get you started with testing and development, they created the Zerynth shield

Which consist of many sensors and actuators 
This can be found here for around 56$

Here's an example of using this shield:
############################################################################################################
# TOI Shield basics
#
# Created by VIPER Team 2015 CC
# Authors: L. Rizzello, G. Baldi, D. Mazzei
############################################################################################################
import streams
import adc
from drivers.toishield import toishield
streams.serial()
# toishield defines pin names in a board indipendent manner
# let’s use them to read raw sensors values
while True:
print(“ Microphone:”,adc.read(toishield.microphone_pin))
print(“ Light:”,adc.read(toishield.light_pin))
print(“Temperature:”,adc.read(toishield.temperature_pin))
print(“ Touch:”,digitalRead(toishield.touch_pin))
# aux pins are also accessible!
print(“ AUX1:”,adc.read(toishield.aux1.ADC))
print(“-”*40)
sleep(500)
# this scripts runs on every supported board, without a single change...cool isn’t it? <img src="http://www.open-electronics.org/wp-includes/images/smilies/simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;">

Looks interesting, right!... now if you want to learn Python... there's a lot of resources:

samedi 27 février 2016

Power a house for 1 day with 1 hour of riding a bike, really ?

Many came across this video stating we can generate power for a house for 1 day by just pedaling for 1 hour.  Really?



Here's a screen shot of the video stopped a 6sec:


We don't see it for a long time, but here's the data.
  • They generate 12 volts
  • At a current of 10 amps
To calculate Power, we multiply those 2, so this is 120 Watts.

Let's explain quickly the difference between Power and Energy before we continue.
  • Power is the rate at which energy is generated or used. The W or kW (thousand) is a unit of power.
  • Energy is a measure of how much Power (fuel) is contained within something, or used by something over a specific period of time. Wh or kWh is a unit of Energy
So to put it simply with the above info, the bike creates 120W of power.  If you can sustain this for 1h, you would have created 120Wh of Energy. If you run this for 2h, you have 120W/2h or 240Wh of Energy.

Now, there is something call the first law of thermodynamics.  It's called a LAW, not a theory.  Laws cannot be broken. The first law state:
The first law, also known as Law of Conservation of Energy, states that energy cannot be created or destroyed in an isolated system.
In simple term, you cannot create more Energy in a system that what was put in.  So, if on my bike I create 120Wh of Energy, then I cannot have more than 120Wh of electrical energy out. Regardless of how many tricks (gears, wheels) and transformations (from 12v DC to 120v AC) you used.

Then you have the second law of thermodynamics. which state:
The second law of thermodynamics states that the entropy of any isolated system always increases.
Simply, this means that you will always have loses in any energy conversions.  In the bike example above, we have (see Wikipedia for numbers)
  • Human power to pedal power conversion
    • We can transfer of to 99% of the energy to the pedal. So loosing 1%
  • Pedal to shaft, mechanical friction
    • You can loose 1% to 7%  in gearing's and 4% to 12% in chains and hubs. So anything from 5% to 19%.  So medium of 12% lost.
  • Shaft to generator output
    • This can vary from 10% to 20% (source). So lets take 15% average.
  • Then you have the electrical loss 
    • Converted: 5% to 15% - average of 10%
    • Batteries : around 25%
So total loss of energy from what you put it to what you can use is (1+12+15+10+25) =  63%

The output showed on the screen shot, is probably after the electric generator, so this is before the electrical loss (10% + 25%).

So you see, there's nothing free about this energy and you need to be an athlete to generate that little energy.

Ok, now let's say we are pedaling for 1h and creating 120Wh of Energy.  We will have 35% loss after that point, if we want to use this electricity.  So we have around 78Wh of electricity saved in the battery and usable after conversion and transport.

What can we do with 78Wh?

Here's a graph of different appliances and their Energy needs.


Conclusion:

To state that this is free energy and that we can power a house for 1 day with 1 hour of pedaling is very misleading.

It maybe true if your house only need a few LED light bulb, no refrigerator, no stove or microwave and maybe one cell phone charger.

And what is the cost of that big bike?

IF we really want to provide electricity for the 1.5 billions who needs it, this is not the solution. Cheap & reliable coal, gas or clean nuclear power is the solution.


Sources used for this:
  • Wikipedia
  • http://www.energylens.com/articles/kw-and-kwh
  • http://www.mpoweruk.com/energy_efficiency.htm
  • http://www.lowtechmagazine.com/2011/05/bike-powered-electricity-generators.html
  • https://www.coursera.org/learn/energy-101
  • https://www.boundless.com/chemistry/textbooks/boundless-chemistry-textbook/thermodynamics-17/the-laws-of-thermodynamics-123/the-three-laws-of-thermodynamics-496-3601/

mardi 23 février 2016

IoT: Installing a MQTT broker

Introduction to MQTT

For my IoT devices, I will be using MQTT to communicate sensor data to clients.

Here's a quick diagram showing how this works.

  • Publisher can be a xBee + temperature sensor, a nodeMCU + humidity sensor, sending topic and data.
  • The broker is the server part receiving the publication from the publishers (sensors) and serving the subscribers, reading the data.
  • Subscribers are the clients subscribing to the topics and getting the data for display, analysis etc.

Installing a broker

In this quick post, I am using the MQTT broker called mosquitto on fedora server 23 x64bit.  Here are the steps to install and test it.

Install
  • dnf install mosquitto.x86_64
Testing
  • ssh1: start mosquitto
    • mosquitto
      1456270790: mosquitto version 1.4.5 (build date 2015-11-27 15:20:56+0000) starting
      1456270790: Using default config.
      1456270790: Opening ipv4 listen socket on port 1883.
      1456270790: Opening ipv6 listen socket on port 1883.
      1456270827: New connection from ::1 on port 1883.
      1456270827: New client connected from ::1 as mosqsub/26144-localhost (c1, k60).
      1456270870: New connection from ::1 on port 1883.
      1456270870: New client connected from ::1 as mosqpub/26149-localhost (c1, k60).
      1456270870: Client mosqpub/26149-localhost disconnected.
  • ssh2: Starts a subscription to the topic "hello/world".
    • mosquitto_sub -d -t hello/world
      Client mosqsub/26499-localhost sending CONNECT
      Client mosqsub/26499-localhost received CONNACK
      Client mosqsub/26499-localhost sending SUBSCRIBE (Mid: 1, Topic: hello/world, QoS: 0)
      Client mosqsub/26499-localhost received SUBACK
      Subscribed (mid: 1): 0
  • ssh3: Publish a first message on the topic "hello/world"
    • mosquitto_pub -d -t hello/world -m "This is my first message"
      Client mosqpub/26511-localhost sending CONNECT
      Client mosqpub/26511-localhost received CONNACK
      Client mosqpub/26511-localhost sending PUBLISH (d0, q0, r0, m1, 'hello/world', ... (24 bytes))
      Client mosqpub/26511-localhost sending DISCONNECT
In the window that started the broker (mosquitto), (ssh1),  you should see:
1456274285: New connection from ::1 on port 1883.
1456274285: New client connected from ::1 as mosqpub/26549-localhost (c1, k60).
1456274285: Client mosqpub/26549-localhost disconnected.

In the window that started the subscription (ssh2), you should see this:
Client mosqsub/26499-localhost received PUBLISH (d0, q0, r0, m0, 'hello/world', ... (24 bytes))
This is my first message
 and from time to time those ping request:
Client mosqsub/26499-localhost sending PINGREQ
Client mosqsub/26499-localhost received PINGRESP
For the above, I used this video for reference.

Windows MQTT client:


Now let's try a MQTT client on Windows.  I found this Chrome extension:
You may need to open the firewall on the server side to open port 1883:
firewall-cmd --add-port=1883/tcp
Then from the MQTTlens, you can now create a new connection like this:

After a save, you should get a connection.
Then you can try the subscribe and publish








We see here that the publish we pushed from the windows client, appeared in the subscription windows of the server. Then we sent from the server "this is my first message" and saw in the on both the server subscription and the client.

 Next step... getting my IoT device talking to the broker.  Hardware ordered!