Installing Ruby:

 

sudo apt-get install -y openssl libreadline6-dev git-core zlib1g libssl-dev libpq-dev 

sudo apt-get install -y libyaml-dev libsqlite3-dev sqlite3

sudo apt-get install -y libxml2-dev libxslt-dev

sudo apt-get install -y autoconf automake libtool bison

cd /usr/src/
sudo wget http://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.gz
sudo tar -xvzf ruby-2.4.0.tar.gz
cd ruby-2.4.0
sudo ./configure --enable-shared --with-openssl-dir=/usr/bin --disable-install-doc --disable-install-rdoc --disable-install-capi 
sudo make install

Before compile: Thu 19 Jan 05:11:11 BRST 2017

After compile: Thu 19 Jan 05:30:19 BRST 2017

It takes around 20 minutes to compile.

Installing Rails without the docs:

sudo gem install rails --no-ri --no-rdoc

you can make it default o not install rubygems documentation:

sudo echo "gem: --no-ri --no-rdoc" >> ~/.gemrc

 

Installing the PostgreSQL:
 

Step 1: Update and Install Packages

First, go ahead and update your Pi's packages:

sudo apt-get update

Once this is finished, you can run the following command to grab and install PostgreSQL:

sudo apt-get install postgresql-9.4

It may take a bit to complete, but once it's done, confirm the installation:

which psql

You should get a result like this:

pi@raspberrypi:~ $ which psql  
/usr/bin/psql

You should now have a fully functional PostgreSQL database server on your Pi! It's that easy!

In the next steps, we'll configure this server to allow access from external clients (i.e. other computers running a server manager, such as pgAdmin).

Step 2: Modify Configuration

By default, PostgreSQL is configured to only allow access to it's databases from the same machine. This is fine for testing, but our aim is to have a centralized, locally accessible database server. To open access for other machines, we'll need to modify a few configuration files.

First, let's modify the pg_hba.conf file. This controls client authentication and is, by default, configured to only allow local access. Before we make any edits, however, we'll want to create a backup of our default configuration:

sudo cp /etc/postgresql/9.4/main/pg_hba.conf /etc/postgresql/9.4/main/pg_hba.conf.bak

Then, enter the following to open the file for editing:

sudo nano /etc/postgresql/9.4/main/pg_hba.conf

At the end of this file, enter the following line:

host     all     all     192.168.0.0/24     md5  

This will allow access from users on our local network (i.e. any client with a 192.168.0.* IP address.

NOTE: You may need to change the first part (192.168) if your router assigns a different network address (like 129.144).

To save your changes to the pg_hba.conf file, enter Ctrl+Xy, and Enter.

Next, we'll need to modify the main postgresql.conf configuration file to allow access from IP addresses other than localhost. But first, make a backup of this file before proceeding:

sudo cp /etc/postgresql/9.4/main/postgresql.conf /etc/postgresql/9.4/main/postgresql.conf.bak

And then:

sudo nano /etc/postgresql/9.4/main/postgresql.conf

And change the following line:

listen_addresses = 'localhost'  

To:

listen_addresses = '*'  

/etc/init.d/postgresql restart

This will allow the PostgreSQL server to accept connections from any IP address. In combination with the changes we made to the pg_hba.conf file, this should allow any clients on the local network access to the server, while still protecting from outside requests. As explained on StackOverflow:

listen_addresses controls which IPs the server will answer on, not which IPs the server will permit connections to authenticate from. It's entirely reasonable and normal to use listen_addresses '*' so the server will accept incoming connections on any ip assigned to an interface on the postgresql server host, while using pg_hba.conf to control access at a finer grained level for which IPs the server will accept logins from for specific databases and users.

After trying alot of things, nothing worked. Using NVM doesnt work. But here is the solution:

vi /etc/opkg/base-feeds.conf

The file will be empty. Put this on the file and save:

src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32

Now follow this commands:

opkg update
opkg install nodejs

After all the work, that is very fast, you will get this:

root@edison:~# node -v                                                                                                          
v0.12.7  

Now, let's see if the segmentation faults will stop. :)

Here is the source: http://alextgalileo.altervista.org/edison-package-repo-configuration-instructions.html

And here is the packages that you can get there: http://repo.opkg.net/edison/repo/core2-32/

i2cdetect -a -r 6 

This will result all the devices addresses that returned the scanning probe.

root@edison:/home# i2cdetect -a -r 6                                                                                                                                        
WARNING! This program can confuse your I2C bus, cause data loss and worse!                                                                                                  
I will probe file /dev/i2c-6 using read byte commands.                                                                                                                      
I will probe address range 0x00-0x7f.                                                                                                                                       
Continue? [Y/n] y                                                                                                                                                           
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f                                                                                                                         
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                                         
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                                         
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                                         
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --                                                                                                                         
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                                         
50: -- -- -- 53 -- -- -- 57 -- -- -- -- -- -- -- --                                                                                                                         
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                                         
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --                                                                                                                         
root@edison:/home#    

This time I was look for the 0x57 device, that I recently connected to the i2c bus.

Get the device data:

i2cdump -y -f 6 0x57 

The result:

root@edison:~# i2cdump -y -f 6 0x57                                                                                             
No size specified (using byte-data access)                                                                                      
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef                                                         
00: 00 00 00 0f 00 00 03 00 00 00 00 00 00 00 00 00    ...?..?.........                                                         
10: 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff    ................                                                         
20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................                                                         
30: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................                                                         
40: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................                                                         
50: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................                                                         
60: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................                                                         
70: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................                                                         
80: 00 00 00 00 00 ff af af af af af af af 01 af af    ......??????????                                                         
90: af af af af af af af af af af af af af af af af    ????????????????                                                         
a0: af af af af af af af af af af af af af af af af    ????????????????                                                         
b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................                                                         
c0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................                                                         
d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................                                                         
e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................                                                         
f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff 05 11    ..............?? 

Get data from an address on the device:

i2cget -y -f 6 0x57 0x06  

Result:

root@edison:~# i2cget -y -f 6 0x57 0x06                                                                                         
0x03       

Send data to the device:

i2cset -y -f 6 0x57 0x06 0x03 

// I2C-6, endereço 57h, registrador 06h, escreve 03h

My NodeMCU are sending data using MQTT to the broker. Then this flow get the topic and the data and save on InfluxDB using its HTTP API.

Screenshot_11

http://flows.nodered.org/flow/5c96cc92d3171b6434bf

In function we have this code:
 

var tokens = msg.topic.split("/");
var dest = tokens[tokens.length-1];
msg.url ="http://localhost:8086/write?db=greenhouse";
msg.payload = tokens[2] + ",device=" + tokens[1] + " value=" + msg.payload;
return msg;

Here is a graphics sample:

Screenshot_12