• Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    First start with unipi / MERVIS

    Scheduled Pinned Locked Moved Mervis
    15 Posts 7 Posters 11.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nordeck
      last edited by

      What do you mean with ST program?
      I had an Idea to build wifi temperature sensor using "mode mcu" (http://www.jerome-bernard.com/blog/2015/10/04/wifi-temperature-sensor-with-nodemcu-esp8266/) and write values into some file on rsb (or somewhre else in local network). Then read this file with mervis. I need update every 5mins.

      1 Reply Last reply
      Reply Quote 0
      • T
        tomas_hora administrators
        last edited by

        In Mervis, there is 'programming language' for PLCs called ST (structured text). It is not that powerful as C so do not expect much, but you are able to do some basic stuff. I will try to take a look at it, if it is possible to read external files (not sure yet). If yes, then you would need to write e.g. a python script to read the temperature from the ESP periodically and write the temperature to a file, which might be read by Mervis.

        G 1 Reply Last reply
        Reply Quote 0
        • N
          nordeck
          last edited by nordeck

          This post is deleted!
          1 Reply Last reply
          Reply Quote 0
          • K
            karel505
            last edited by

            Thank you for your replies, that was what I needed. For now.
            I did get mervis to work in a very simple setup.
            Learning a lot, it is fun.

            1 Reply Last reply
            Reply Quote 0
            • L
              lindseynicole010
              last edited by lindseynicole010

              thanks for that.

              1 Reply Last reply
              Reply Quote 0
              • P
                pratvictor @tomas_hora
                last edited by

                @tomas_hora said in First start with unipi / MERVIS:

                The default password for root of the mervisOS is: unipi

                @karel505 I do not understand what is your question... The mervisOS is a Deb Jessie only with installed mervis. If you wish to disable it, just run

                systemctl stop configtool
                systemctl stop sharkrt
                systemctl disable configtool
                systemctl disable sharkrt
                

                The FileSystem is readonly so if you wish to write to any file

                mount -o remount,rw /
                

                and then mount it as redonly again by

                mount -o remount,ro /
                

                @nordeck If the IP address has changed, you need to atach the PLC(UniPi) again. If you mean the battery for RTC, then it is CR2032.

                If I want to set an static ip to the raspberry, I should do it that way? Could I do it trough Mervis? I didn't find how to set an static IP...

                Thanks!!

                T 1 Reply Last reply
                Reply Quote 0
                • T
                  tomas_hora administrators @pratvictor
                  last edited by

                  @pratvictor if you are using mervis, then you can of course set static IP using the IDE. Just select the PLC chek the network properities on the right side. You have to upload the configuration afterwards (acessible from right click on PLC)

                  1 Reply Last reply
                  Reply Quote 0
                  • G
                    Giamba @tomas_hora
                    last edited by

                    This post is deleted!
                    G 1 Reply Last reply
                    Reply Quote 0
                    • G
                      Giamba @Giamba
                      last edited by

                      @Giamba said in First start with unipi / MERVIS:

                      @tomas_hora

                      In Mervis you can create a Modbus TCP channel that then connects to another program on the local machine or on a network machine. It is enough then to create a program in C with the library modbus, in the example that follows, I also use the library zmq which gives me real-time messages from any program, from everywhere. This one gives me the data of my weather station WMR200.

                      > #include <stdio.h>
                      > #include <unistd.h>
                      > #include <string.h>
                      > #include <stdlib.h>
                      > #include <errno.h>
                      > 
                      > #include <modbus.h>
                      > #include <zmq.h>
                      > #include "zhelpers.h"
                      > 
                      > int arrondi(float nombre) {
                      >   return nombre + 0.5;
                      > }
                       
                      > int main()
                      > {
                      >     int socket;
                      >     modbus_t *ctx;
                      >     modbus_mapping_t *mb_mapping;
                      >     int keepRunning;
                      >     int rc;
                      >     char src[sizeof("WMR200_USB")];
                      >     char pressure[sizeof("0000.0")];
                      >     char humid0[sizeof("000.0")];
                      >     char humid1[sizeof("000.0")];
                      >     char temp0[sizeof("-000.0")];
                      >     char temp1[sizeof("-000.0")];
                      >     char windGust[sizeof("000.0")];
                      >     char windAvg[sizeof("000.0")];
                      >     char windDir[sizeof("000.0")];
                      > 
                      >     char zmq_msg[100];
                      >     
                      > 
                      >     printf("Start WView WMR200 ZMQ/Modbus gateway\r\n");
                      >     fflush(stdout);
                      >     
                      >     keepRunning = 1;
                      >     while(keepRunning == 1) {
                      >         printf("Waiting for TCP connection...\r\n");
                      >         fflush(stdout);
                      >         ctx = modbus_new_tcp("127.0.0.1", 1502);
                      >         socket = modbus_tcp_listen(ctx, 1);
                      >         modbus_tcp_accept(ctx, &socket);
                      >         printf("TCP connection started!\r\n");
                      >         fflush(stdout);
                      > 
                      > 
                      >         mb_mapping = modbus_mapping_new(1000, 1000,
                      >                                         1000, 1000);
                      > 
                      >         mb_mapping->tab_registers[0] = 0; //pressure
                      >         mb_mapping->tab_registers[1] = 0; //temp sensor 0 temp  (station temp)
                      >         mb_mapping->tab_registers[2] = 0; //temp sensor 0 humid
                      >         mb_mapping->tab_registers[4] = 0; ///temp sensor 1 temp (out temp)
                      >         mb_mapping->tab_registers[5] = 0; //temp sensor 1 humid
                      >         mb_mapping->tab_registers[7] = 0; //wind gust
                      >         mb_mapping->tab_registers[8] = 0; //wind avg
                      >         mb_mapping->tab_registers[9] = 0; //wind dir
                      > 
                      > 
                      >         if (mb_mapping == NULL) {
                      >             fprintf(stderr, "Failed to allocate the mapping: %s\r\n",
                      >                     modbus_strerror(errno));
                      >             modbus_free(ctx);
                      >             return -1;
                      >         }
                      > 
                      >         void *context = zmq_ctx_new ();
                      >         void *subscriber = zmq_socket (context, ZMQ_PULL);
                      >         rc = zmq_bind (subscriber, "tcp://*:5560");
                      >         assert(rc == 0);
                      > 
                      > 
                      >         while(1) {
                      >             memset(zmq_msg, 0, sizeof(zmq_msg));
                      >             int size = zmq_recv (subscriber, zmq_msg, 2048, ZMQ_DONTWAIT);
                      >             if (size != -1) {
                      >                 //  Process task
                      > 
                      >                 //printf("%s\n\r", zmq_msg);
                      >                 fflush(stdout);
                      >                 sscanf (zmq_msg, "%s %s %s %s %s %s %s %s %s",src, pressure, temp0, humid0, temp1, humid1, windGust, windAvg, windDir);
                      >                 printf("WMR200 Modbus Gateway from ZMQ: topic=%s pressure=%s temp0=%s humid0=%s temp1=%s humid1=%s winGust=%s windAvg=%s windDir=%s\r\n", src, pressure, temp0, humid0, temp1, humid1, windGust, windAvg, windDir);
                      >                 fflush(stdout);
                      >                 if (strcmp(src, "WMR200_USB") ==0){
                      >                     mb_mapping->tab_registers[0] = arrondi(atof(pressure)); //pressure
                      >                     mb_mapping->tab_registers[1] = arrondi(atof(temp0)*10); //temp sensor 0 temp  (station temp)
                      >                     mb_mapping->tab_registers[2] = arrondi(atof(humid0)*10); //temp sensor 0 humid
                      >                     mb_mapping->tab_registers[3] = arrondi(atof(temp1)*10); ///temp sensor 1 temp (out temp)
                      >                     mb_mapping->tab_registers[4] = arrondi(atof(humid1)*10); //temp sensor 1 humid
                      >                     mb_mapping->tab_registers[5] = arrondi(atof(windGust)*10); //wind gust
                      >                     mb_mapping->tab_registers[6] = arrondi(atof(windAvg)*10); //wind avg
                      >                     mb_mapping->tab_registers[7] = arrondi(atof(windDir)*10); //wind dir
                      >                 }
                      >             }
                      > 
                      >             uint8_t query[MODBUS_TCP_MAX_ADU_LENGTH];
                      >             rc = modbus_receive(ctx, query);
                      >             if (rc >= 0) {
                      >                 //printf("Replying to request.\r\n");
                      >                 modbus_reply(ctx, query, rc, mb_mapping);
                      >                 //fflush(stdout);
                      >             } else {
                      >                 printf("Quit the loop: %s\r\n", modbus_strerror(errno));
                      >                 fflush(stdout);
                      >                 zmq_close (subscriber);
                      >                 zmq_ctx_destroy (context);
                      >                 modbus_mapping_free(mb_mapping);
                      >                 close(socket);
                      >                 modbus_free(ctx);
                      >                 break;
                      >             }
                      >         }   
                      >     }
                      >     return 0;
                      > }
                      

                      Then in Mervis you have to configure modbus data point.

                      C 1 Reply Last reply
                      Reply Quote 0
                      • C
                        CaitC @Giamba
                        last edited by

                        @Giamba I see that you are posting C source. I have found python in /usr/bin but I do not find any gcc or make anywhere. There is also no java installed. I am not an RPi user (I use nV embedded systems) so am not familiar with Jessie ... do I need to install these programming runtimes and environments? Do you know what size SD card I need to get to this environment?

                        1 Reply Last reply
                        Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • First post
                          Last post